VariousArtists=[["Various Artists"],["Lady GaGa"],["Michael Jackson"],["Muse"],["Various Artists : Hits Attitude"],["Eminem"],["Myl\u00e8ne Farmer"],["Coldplay"],["Alain Bashung"],["Bob Marley"],["Tryo"],["Akon"],["Black Eyed Peas"],["U2"],["Linkin Park"],["David Guetta"],["Coeur De Pirate"],["Bob Marley & The Wailers"],["Red Hot Chili Peppers"],["Calogero"],["Serge Gainsbourg"],["Various Artists : Balance Le Son"],["Various Artists : Music From The Original Motion Picture International"],["olivia ruiz"],["Zazie"],["Les Ogres de Barback"],["Jason Mraz"],["Radiohead"],["Lily Allen"],["Kanye West"],["Various Artists : M Hits"],["Queen"],["Katy Perry"],["Dr. Dre"],["The Pussycat Dolls"],["System of a Down"],["Various Artists : Nrj Music Awards"],["Pink Floyd"],["Amy Macdonald"],["James Morrison"],["Francis Cabrel"],["The Wailers"],["Georges Brassens"],["Gregoire"],["Johnny Hallyday"],["Lil' Wayne"],["Pep's"],["Madonna"],["Rihanna"],["Jacques Brel"],["50 Cent"],["A.R. Rahman"],["Renaud"],["Nelly Furtado"],["Julien Dore"],["Adam Clayton"],["The Rolling Stones"],["Marshall Mathers"],["Mika"],["Nirvana"],["P!nk"],["Groundation"],["The Offspring"],["Green Day"],["Tracy Chapman"],["Superbus"],["Duffy"],["MGMT"],["Various Artists : Triple Les Plus Belles Chansons Francaises"],["Larry Mullen"],["Michel Sardou"],["Daft Punk"],["Led Zeppelin"],["Hans Zimmer"],["Mia"],["Jean-Jacques Goldman"],["Martin Solveig"],["WAX TAILOR"],["Booba"],["Lenny Kravitz"],["Amy Winehouse"],["Tom Frager"],["Paramore"],["Renan Luce"],["Bob Sinclar"],["Benabar"],["Moby"],["Rammstein"],["Yann Tiersen"],["Stacy Ferguson"],["Britney Spears"],["M"],["LA RUE KETANOU"],["Charlie Winston"],["Dr"],["Various Artists : Promo Only Mainstream Radio"],["Colby O'Donis"],["Various Artists : Good Morning England Standard E"],["Beyonce"],["Marc Lavoine"],["Pink"],["Placebo"],["Various Artists : Nrj Hits"],["Snoop Dogg"],["James Blunt"],["Daniel Balavoine"],["James Brown"],["Depeche Mode"],["Various Artists : Nova Tunes"],["Massive Attack"],["Christophe Mae"],["Busta Rhymes"],["Ben Harper"],["Timbaland"],["Vanessa Paradis"],["Justin Timberlake"],["Flo-Rida"],["The Doors"],["Charles Aznavour"],["Metallica"],["Stanislas"],["Noir D\u00e9sir"],["Pascale Picard"],["Raphael"],["Enrique Iglesias"],["William Adams"],["Louise Attaque"],["Colbie Caillat"],["Jay-Z"],["David Bowie"],["The Killers"],["Will.I.Am"],["Stevie Wonder"],["Ayo"],["Nightwish"],["Dire Straits"],["Sting"],["Jack Johnson"],["Jamiroquai"],["INDOCHINE"],["Yodelice"],["Marvin Gaye"],["Fall Out Boy"],["Bertrand Cantat"],["Guns N' Roses"],["Sean Paul"],["Eric Clapton"],["Ne-Yo"],["Empire Of The Sun"],["Ray Charles"],["Mariah Carey"],["Enya"],["Gwayav'"],["Various Artists : Mega"],["The Cranberries"],["Soprano"],["Air"],["Evanescence"],["Johann Sebastian Bach"],["Various Artists : Slumdog Millionaire"],["Elton John"],["Tiken Jah Fakoly"],["Various Artists : Nrj Hit List"],["Seal"],["Morcheeba"],["Chinese Man"],["Chris Brown"],["Nina Simone"],["Arctic Monkeys"],["Sum 41"],["Fatals Picards"],["ABBA"],["Nicole Scherzinger"],["M. Batson"],["Bernard Lavilliers"],["Various Artists : Un Diner Presque Parfait"],["The Edge"],["D. Parker"],["Gabriella Cilmi"],["Justice"],["Portishead"],["Aliaune \"Akon\" Thiam"],["Melody Gardot"],["The Cure"],["Rohff"],["Aaron"],["Manu Chao"],["Dionysos"],["Grand Corps Malade"],["Justin Nozuka"],["Jimi Hendrix"],["Henri D\u00e8s"],["The Police"],["IAM"],["Bob Dylan"],["Florent Pagny"],["Nickelback"],["John Williams"],["Khaled"],["Maxime Le Forestier"],["Kings of Leon"],["Ennio Morricone"],["Celine Dion"],["Michel Polnareff"],["Dub Incorporation"],["Supertramp"],["Norah Jones"],["Diana Krall"],["Michel Berger"],["Franz Ferdinand"],["Avril Lavigne"],["Thomas Dutronc"],["Marilyn Manson"],["Les cowboys fringants"],["Gaetan Roussel"],["Birdy Nam Nam"],["cocoon"],["Elvis Presley"],["Dido"],["The Ting Tings"],["Salvatore Adamo"],["Jamie Cullum"],["La Grande Sophie"],["Gorillaz"],["Various Artists : Of The"],["Jean Fauque"],["Various Artists : The"],["Otis Redding"],["G\u00e9rald de Palmas"],["Phil Collins"],["Prince"],["The Who"],["Keri Hilson"],["Lucas"],["Aerosmith"],["W. Hector"],["J. Jeberg"],["Les Wriggles"],["Paul Hewson"],["Phoenix"],["The Kooks"],["R. Kelly"],["Rage Against The Machine"],["Ghinzu"],["Alain Souchon"],["Ana\u00efs"],["Telephone"],["Scorpions"],["Kid Cudi"],["Fran\u00e7ois Rauber"],["Magic System"],["A. Young"],["Allan Pineda"],["Aretha Franklin"],["Korn"],["Mick Jagger"],["Sheryl Crow"],["R.E.M."],["Alpha Blondy"],["Camille"],["Johnny Cash"],["T. Lawrence"],["T-PAIN"],["T.I."],["Stan Getz"],["The Clash"],["Milow"],["Various Artists : Starfloor"],["Jaime Gomez"],["Beth Gibbons"],["Ella Fitzgerald"],["Damian Marley"],["Chris Cornell"],["Pitbull"],["Archive"],["Jeff Buckley"],["Keane"],["Moriarty"],["Alicia Keys"],["The Cardigans"],["Grace"],["Curtis Jackson"],["Bonobo"],["Les fatals Picards"],["BJORK"],["Louis Armstrong"],["The Pixies"],["Sheryfa Luna"],["Joe Dassin"],["Emily Loizeau"],["Neil Young"],["Usher"],["Janis Joplin"],["Lady Gaga, Colby O'Donis"],["Laurent Wolf"],["La Chanson Du Dimanche"],["Katie Melua"],["The White Stripes"],["Danny Elfman"],["Estelle"],["Bryan Adams"],["Claude Nougaro"],["bruce springsteen"],["Weezer"],["Edith Piaf"],["Eddy Mitchell"],["L\u00e9o Ferr\u00e9"],["Matmatah"],["Geoff Barrow"],["The Kinks"],["Various Artists : Alternative Times"],["Mozart Opera Rock"],["Frank Sinatra"],["Oceana"],["Cascada"],["Santogold"],["Apl. De Ap"],["Red One"],["Kylie Minogue"],["Pink Martini"],["Feist"],["Kery James"],["Mary J. Blige"],["Diana Ross"],["Christophe Willem"],["Sia"],["Barbara"],["Mikkel S. Eriksen"],["Julien Clerc"],["Genesis"],["Emilie Simon"],["Gwen Stefani"],["Slipknot"],["Lionel Richie"],["Various Artists : Promo Only Modern Rock Radio"],["TILL LINDEMANN"],["PAUL LANDERS"],["DOKTOR CHRISTIAN LORENZ"],["W. Axl Rose"],["Manu Larrouy"],["asa"],["Era"],["John Lennon"],["Robbie Williams"],["Christina Aguilera"],["Leona Lewis"],["Various Artists : Bravo Hits"],["Junior Caldera"],["CHRISTOPH DOOM SCHNEIDER"],["Brian Eno"],["Claude Francois"],["David_Vendetta"],["Various Artists : Now That What I Call Music"],["Simple Plan"],["Bloc Party"],["Starsailor"],["Gotan Project"],["Guru Josh Project"],["Helmut Fritz"],["St\u00e9phane Rancourt"],["Phil Morissette"],["Cypress Hill"],["The Beach Boys"],["Cat Stevens"],["Shakira"],["Dalida"],["Various Artists : Je Vais Bien"],["Various Artists : Motown International"],["Studio Group"],["Vangelis"],["Lara Fabian"],["Noir D"],["Lionel Florence"],["Les Rita Mitsouko"],["Wyclef Jean"],["MC Solaar"],["Chakib Chambi"],["Joy Division"],["Traditionnel"],["Didier Super"],["Jackson 5"],["The Chemical Brothers"],["Carla Bruni"],["Tete"],["Yannick Noah"],["Thievery Corporation"],["Hugues Aufray"],["Snow Patrol"],["Deep Purple"],["Within Temptation"],["Django Reinhardt"],["Peter Doherty"],["H\u00e9l\u00e8ne Segara"],["BassHunter"],["Creedence Clearwater Revival"],["Scarlett Johansson"],["Alanis Morissette"],["Various Artists : Slow Blues"],["Thomas Fersen"],["Blink-182"],["Coeur De Pirate, Julien Dor\u00e9"],["Various Artists : Tubes Rtl"],["Leonard Cohen"],["Fatboy Slim"],["Mozart"],["Nate Dogg"],["Alesha Dixon"],["Brandon Flowers"],["Beck"],["Zee Avi"],["Volo"],["Kardinal Offishall"],["Whitney Houston"],["Tom Frager, Gwayav'"],["Kara DioGuardi"],["Patricia Kaas"],["Roger Hodgson"],["UB40"],["Stanislas Renoult"],["Various Artists : Sex And The City"],["Barry White"],["Patrice"],["The Prodigy"],["Sebastien Tellier"],["Patrick Bruel"],["sade"],["SIMON & GARFUNKEL"],["Serge Lama"],["Cali"],["2Pac"],["Benjamin Biolay"],["Ben"],["James Morrison, Nelly Furtado"],["Ciara"],["Kaiser Chiefs"],["Morrissey"],["Amel Bent"],["Various"],["Yeah Yeah Yeahs"],["Wolfgang Amadeus Mozart"],["The Fray"],["Shaggy"],["Cl\u00e9ment Marchand"],["Michel Delpech"],["Salif Keita"],["Benny Andersson"],["Nas"],["ZZ Top"],["Zero 7"],["Rose"],["Disturbed"],["Mark Stoermer"],["Eddie Vedder"],["Various Artists : Triple Les Intemporelles De La Chanson Francaise"],["Jean-Michel Jarre"],["Berurier Noir"],["John Mayer"],["Lynyrd Skynyrd"],["Aldebert"],["Bee Gees"],["Apocalyptica"],["Miranda Cooper"],["Alela Diane Menig"],["PJ Harvey"],["Max Martin"],["The Virgins"],["CocoRosie"],["Blur"],["Boney M."],["Various Artists : Hollywood Planet Rock"],["George Michael"],["Vivaldi"],["Queens of the Stone Age"],["DJ Shadow"],["Dave Keuning"],["The Velvet Underground"],["By Kilerslancien\/Zaho"],["Pierpoljak"],["Sinik"],["Santana"],["Olivier Miller"],["Tor Erik Hermansen"],["Shy'm"],["F\u00e9f\u00e9"],["Blondie"],["Various Artists : Ministry Of Sound Chillout Classics"],["Kenza Farah"],["Nikesha Briscoe"],["Berliner Philharmoniker [Orchestra]"],["Tim Mosley"],["Jenifer"],["Duke Ellington"],["Robin Thicke"],["Ratatat"],["Steve Angelo"],["Fraser T. Smith"],["Sophie Hunger"],["Laurent Boutonnat"],["Foo Fighters"],["Debout Sur Le Zinc"],["Miles Davis"],["Brian Higgins"],["gregory lemarchal"],["Sly Dee, Z\u00e9 Mat\u00e9o, High Ku"],["Diam's"],["The Strokes"],["Miossec"],["Boris Bergman"],["Bach, Johann Sebastian [Composer]"],["The Do"],["Arthur Gillette"],["Stereophonics"],["James Newton Howard"],["Craig David"],["Tim Rice-Oxley"],["Tom Chaplin"],["Iggy Pop"],["Nneka"],["Pete Yorn"],["Beirut"],["Patrice Guirao"],["Tricky"],["Kool & The Gang"],["The Last Shadow Puppets"],["Jean Ferrat"],["Various Artists : Classic French Songs"],["Yael Naim"],["Saez"],["Brandy"],["Eagles"],["Various Artists : Folk Proud"],["Various Artists : Hip Hop"],["Patrick Stump"],["Arthur H"],["Vivaldi, Antonio [Composer]"],["Joe Cocker"],["Les Enfoires"],["OneRepublic"],["Papa Roach"],["Sergio Mendes"],["Isaac Hayes"],["Alain Goraguer"],["Lou Reed"],["Various Artists : Encyclopedia Of Pop"],["Various Artists : Contact Play Dance"],["Pete Yorn, Scarlett Johansson"],["Herbert von Karajan [Conductor]"],["Jena Lee"],["The Dandy Warhols"],["Clarika"],["Mano Negra"],["Iron Maiden"],["Eels"],["Nada Surf"],["Antonio Carlos Jobim"],["SINSEMILIA"],["Damien Rice"],["Pascal Obispo"],["Jr."],["Kasabian"],["Burning Spear"],["Nyanda Thorbourne"],["Benny Benassi"],["The Corrs"],["Vika Jigulina"],["Edward Maya"],["Chris Isaak"],["R\u00f6yksopp"],["Herbie Hancock"],["Pat Metheny"],["Bono"],["Akhenaton"],["Simian"],["Kruder & Dorfmeister"],["Erykah Badu"],["Andy Hurley"],["Ariane Moffatt"],["Chopin"],["Bon Jovi"],["Madcon"],["John Lee Hooker"],["Pearl Jam"],["Various Artists : Jiwa Hours Party By Repie Fp"],["Ken Pendergast"],["Antonio"],["Peter Svensson"],["Method Man"],["Raphael Saadiq"],["Shaffer Smith"],["Alela Diane"],["Various Artists : Funk"],["David Evans"],["Young Jeezy"],["Vampire Weekend"],["Maurane"],["Various Artists : My Perfect List"],["Yves Duteil"],["Al Green"],["Limp Bizkit"],["Missy Elliott"],["Chuck Berry"],["Jean-Philippe Rameau"],["Fire"],["Kurt Cobain"],["Earth"],["Wind"],["Eric Prydz"],["Gregory Isaacs"],["Mark Knopfler"],["The Script"],["P. Diddy"],["B.B. King"],["Izia"],["Jacques Revaux"],["Cozi"],["David Guetta, Akon"],["St. Germain"],["gerard darmon"],["Kate Nash"],["The Bloody Beetroots"],["The All-American Rejects"],["Eminem, Dr. Dre, 50 Cent"],["Busta Rhymes, Estelle"],["Incubus"],["Adrienne Pauly"],["Various Artists : Now Spring"],["SEFYU"],["Rick Ross"],["Marina"],["John Stargasm"],["The Hives"],["Andre R. Young"],["Donna Summer"],["Seth Gueko"],["Gilbert Montagn\u00e9"],["V\u00e9ronique Sanson"],["India.Arie"],["N.E.R.D"],["Philippe Paradis"],["Vitalic"],["Bach"],["Brian Holland"],["svinkels"],["Saul Hudson"],["Jeffrey Isbell"],["Amaury Salmon"],["Various Artists : Promo Only Alternative Club"],["Various Artists : Top Gear Anthems"],["The Verve"],["Michel Legrand"],["Erik Coomes"],["Bill Withers"],["James Horner"],["Toots & The Maytals"],["Seether"],["Lea Castel"],["Good Charlotte"],["Various Artists : Promo Only Urban Radio"],["LA FOUINE"],["Vincent Delerm"],["RICHARD Z. KRUSPE"],["Laura Pausini"],["The Pierces"],["Emmanuel Moire"],["Zebda"],["Kt Tunstall"],["Joan Jett"],["The Animals"],["Alexandre Castagnetti"],["Nancy Sinatra"],["Jean Pierre Pilot"],["Black Sabbath"],["His Orchestra"],["Hakimakli"],["Gnarls Barkley"],["Tim Larcombe"],["Nouvelle Vague"],["The Smashing Pumpkins"],["The Temptations"],["Jonas Brothers"],["Les Valentins"],["KYO"],["Fergie"],["Howard Shore"],["Abd Al Malik"],["Garbage"],["Various Artists : Classic Cuts Night"],["30 Seconds to Mars"],["Various Artists : Europe L"],["Bat For Lashes"],["Versaillesstation"],["S. Smith"],["Jennifer Ayache"],["Kevin Rudolf"],["Various Artists : L Annee Du Zouk"],["Burt Bacharach"],["Stephan Eicher"],["Eric Serra"],["Toto"],["Muddy Waters"],["Goran Bregovic"],["Lynda Lemay"],["Lauryn Hill"],["Jeff Bhasker"],["Mickey 3D"],["Cat Power"],["The Puppini Sisters"],["Antoine Clamaran"],["Joe Satriani"],["Jamie Lidell"],["Goldfrapp"],["John Legend"],["Blank & Jones"],["Simon Gallup"],["The Supremes"],["Marc Antoine"],["Pharrell Williams"],["Stanislas, Calogero"],["Jimi Hendrix Experience"],["Rokia Traore"],["Tom Waits"],["Kat DeLuna"],["Aphex Twin"],["Psy 4 de la Rime"],["Three Days Grace"],["No Doubt"],["Lamont Dozier"],["Joan Baez"],["Les Wampas"],["Data"],["Axel Bauer"],["Tool"],["Sofia Essaidi"],["Common"],["Supr\u00eame NTM"],["Sniper"],["D. Carter"],["Lamb"],["Sharleen Spiteri"],["Mike Oldfield"],["Gary Jules"],["VA"],["Various Artists : Promo Only Urban Club"],["Static Major"],["Clint Mansell"],["Diederichs Gilles"],["Fran\u00e7ois Feldman"],["Jimmy Cliff"],["Beethoven, Ludwig van [Composer]"],["Jeanne Cherhal"],["Prodigy"],["Christophe"],["Various Artists : Ytmnd"],["Enrico Macias"],["Maroon 5"],["NTM"],["Iron & Wine"],["The Game"],["Kelly Clarkson"],["Nico"],["William Sheller"],["Paul McCartney"],["Texas"],["Sizzla"],["Miley Cyrus"],["Various Artists : Erotic Lounge Bare Jewels"],["Quincy Jones"],["Plain White T's"],["Berry Gordy Jr."],["Joe Trohman"],["Andre Merritt"],["Brian Seals"],["Tri Yann"],["Boby Lapointe"],["Sam Cooke"],["The Sugar Hill Gang"],["Hocus Pocus"],["Ludacris"],["Peter Gabriel"],["Discobitch"],["Survivor"],["Pendulum"],["Erik Satie"],["Robert Smith"],["The Jacksons"],["Sly Dee"],["High Ku"],["Z\u00e9 Mat\u00e9o"],["Elephant Man"],["Mathieu Edward"],["Daddy Yankee"],["Rachid Taha"],["Berry"],["Aaliyah"],["Mike Brant"],["Deryck Whibley"],["Nana Mouskouri"],["Lee Fields"],["Denis Barthe"],["Yuksek"],["Babyshambles"],["Georges Moustaki"],["Cesaria Evora"],["Loney"],["Dear"],["Elliott Smith"],["Didier Barbelivien"],["Steve Jablonsky"],["Epica"],["Keziah Jones"],["Astrud Gilberto"],["T. Mosley"],["Faudel"],["Billie Holiday"],["Redman"],["Loney, Dear"],["Carter Burwell"],["Barrington Levy"],["Multi Interpr\u00e8tes"],["Shurik'n"],["The Gossip"],["Chimene Badi"],["Nadiya"],["Daniel Lanois"],["Various Artists : Mega Disco"],["Michel Colombier"],["Puppetmastaz"],["Various Artists : Erotic Lounge"],["Malik Yusef Jones"],["Ridan"],["Babylon Circus"],["Brick & Lace"],["Van Morrison"],["Manau"],["Serge Reggiani"],["George Benson"],["Nino Ferrer"],["Patti Smith"],["Tom Jones"],["Sophie Delila"],["Tito Puente"],["Stig Anderson"],["Kelly Rowland"],["Pauline"],["Hooverphonic"],["Zaza Fournier"],["Nobuo Uematsu"],["Various Artists : Les Titres Essentiels Reggae"],["Various Artists : D Une Seule Voix"],["Eduardo Makaroff"],["Oscar Peterson"],["Sex Pistols"],["Pierre Perret"],["X-Ray Dog"],["Charlotte Savary"],["Various Artists : Greatest Ever Rock The Definitive Collection"],["Groove Armada"],["Hoosiers"],["Francesco"],["GEMINIANI"],["Tina Turner"],["Various Artists : Rocknrolla"],["Keen' V"],["MAUSS"],["Kiss"],["Armin van Buuren"],["Daphne"],["Roy Ayers"],["Harry Gregson-Williams"],["Nine Inch Nails"],["Micky Green"],["OutKast"],["Jimi Hendrix, Jimi Hendrix Experience"],["John Powell"],["Various Artists : Hits"],["Boards of Canada"],["Mademoiselle K"],["Max Romeo"],["Gipsy Kings"],["Sebastien Hoog"],["Brian McKnight"],["Martin Solveig, Chakib Chambi"],["Vitaa"],["OLIVER RIEDEL"],["Oldelaf & monsieur D"],["Stephen Marley"],["Pierre Delano\u00eb"],["t.A.T.u."],["DMX"],["Lifehouse"],["Charles Trenet"],["Hans Zimmer, James Newton Howard"],["Dave Grohl"],["Thomas Newman"],["Celia Cruz"],["Paolo Nutini"],["Patrick Fiori"],["Eagle-Eye Cherry"],["US3"],["Arcade Fire"],["Jenny-Bea Englishman"],["Various Artists : The Very Power Ballads Greatest Driving Anthems Ever"],["Loreena McKennitt"],["T.I feat Rihanna"],["Alana Filippi"],["Madness"],["Mahalaxmi Iyer"],["Various Artists : Un Hexagone Pop Multicolore"],["Chris Martin"],["Christian Chevallier"],["Gonzales"],["113"],["Booty Luv"],["SIGUR ROS"],["TTC"],["Rodney Jerkins"],["Telepopmusik"],["Klaus Meine"],["Steve Aoki"],["Stephane Grappelli"],["Tina Arena"],["Various Artists : Menace Sur La Planete Rap"],["Kool Shen"],["Beastie Boys"],["Neneh Cherry"],["J\u00e9r\u00f4me Dubois"],["Java"],["The Roots"],["Van Halen"],["Marianne Groves"],["Various Artists : Motown Love International"],["Steve Edwards"],["DJ Krush"],["Deftones"],["DJ Oriska"],["Ocean Drive"],["K'naan"],["Girls in hawaii"],["Rufus Wainwright"],["Laurent Voulzy"],["Brigitte Fontaine"],["Benassi Bros"],["Big Ali"],["Jean-Louis Aubert"],["Travis"],["Michel Jonasz"],["Elan"],["Desaparecidos"],["Various Artists : Et Si On Arretait D Ecouter De La Soupe"],["Capleton"],["The Beatles"],["Joseph D'Anvers"],["Revolver"],["Liane Foly"],["Ultra vomit"],["Introducing Niia"],["Boris Vian"],["Lee \"Scratch\" Perry"],["Tanvi Shah"],["Diederichs"],["Billy Idol"],["Horace Andy"],["Nolwenn Leroy"],["Vince Mendoza"],["Suzanne"],["Rise Against"],["EZ3kiel"],["Jean Felix Lalanne"],["A.R. Rahman, The Pussycat Dolls, Nicole Scherzinger"],["Hoobastank"],["John Butler Trio"],["Roberto Alagna"],["Niagara"],["Tristan Nihouarn"],["Gym Class Heroes"],["Lykke Li"],["The Lyndhurst Orchestra"],["Gavin Greenaway [Conductor]"],["Eurythmics"],["Curtis Mayfield"],["London Symphony Orchestra"],["Rod Stewart"],["Various Artists : The Rap"],["Various Artists : Platinum Series"],["Claire Keim"],["Joy Ogunmakin"],["Tom DeLonge"],["Eagles of Death Metal"],["Monsieur Roux"],["Agnes"],["3 Doors Down"],["Jefferson Airplane"],["Various Artists : Musiques De Mariage"],["Jennifer Lopez"],["Various Artists : Cool"],["Bullet For My Valentine"],["Gary Lightbody"],["Phillipe Cohen Solal"],["Jean-Francois Berger"],["Jacques Dutronc"],["Dolores O'Riordan"],["Keyshia Cole"],["Roch Voisine"],["Adam Roberts"],["Will Smith"],["Craig Armstrong"],["Magyd Cherfi"],["Joe Hisaishi"],["Audioslave"],["September"],["Daniel Powter"],["Lil Jon"],["Tammi Terrell"],["Various Artists : Years Disco"],["Demon One"],["Fugees"],["Earth, Wind, Fire"],["Various Artists : Good Morning England"],["Nathan Connolly"],["Razorlight"],["Klaus Badelt"],["H"],["Dream Theater"],["Ozzy Osbourne"],["E. Dean"],["V. Brown"],["BB Brunes"],["Omondi Olwago"],["Shamel Shepherd"],["Various Artists : After Hours"],["Amon Tobin"],["Hard-Fi"],["William Balde"],["Gilbert Becaud"],["Fonky Family"],["Freddie Perren"],["Patrick Sebastien"],["Crustation"],["Electric Light Orchestra"],["Various Artists : German Top Single Charts"],["Keith Jarrett"],["Theron Thomas"],["Disiz La Peste"],["Winston Mcanuff"],["Author"],["adele"],["Elles"],["Katerine"],["Fedde Le Grand"],["Kevin Bonnet"],["Stevie Ray Vaughan"],["Soldat Louis"],["La Musique De B\u00e9b\u00e9"],["Akon, Kardinal Offishall"],["The Stooges"],["Various Artists : Reggae Gold"],["Cream"],["Music Is Not Fun"],["Simon Hale"],["Soulja Boy Tell`em"],["Paco de Lucia"],["J. McCarty"],["Timothy Thomas"],["Nina Persson"],["Nailah Thorbourne"],["Children of Bodom"],["Stephane Pompougnac"],["Bajka"],["Various Artists : Essential"],["Tunisiano"],["Fabrice Vanvert"],["The Smiths"],["Pauline Croze"],["Karen Mulder"],["Various Artists : Hotel Costes"],["John Coltrane"],["Billy Ze Kick et Les Gamins En Folie"],["Jessy Matador"],["Isabelle Boulay"],["Jean-Loup Dabadie"],["Makali"],["Scooter"],["Karaoke - Ameritz"],["Various Artists : Kuschelrock"],["Alice Russell"],["Jonny Quinn"],["Various Artists : Kill Bill"],["Kassav"],["Wu-Tang Clan"],["Jehro"],["The Turtles"],["Interpol"],["Sylvie Vartan"],["Tears for Fears"],["a-ha"],["John Dahlback"],["Caetano Veloso"],["Noisettes"],["Fatal Bazooka"],["Various Artists : Dirtydancing"],["Martha Reeves"],["Frank Zappa"],["Daniel Bedingfield"],["Various Artists : Good Morning Vietnam"],["Rosemary Standley"],["Ludovico Einaudi"],["Shania Twain"],["Ida Corr"],["I'm From Barcelona"],["Armand Amar"],["Peter Tosh"],["Laura Izibor"],["Tokio Hotel"],["Mobb Deep"],["E. Bogart"],["Henri Salvador"],["D. Quinones"],["E. Nuri"],["Walter Master J"],["Various Artists : Promo Only Caribbean Series"],["Various Artists : A Lot Like Love"],["Madeleine Peyroux"],["Michael Kamen"],["Jian Wang [Cello]"],["Simple Minds"],["David Tavare"],["Martha Reeves & The Vandellas"],["Cyndi Lauper"],["Tosca"],["Destiny's Child"],["The Vandellas"],["dEUS"],["Batlik"],["R. Fair"],["Inner Circle"],["Just Jack"],["Gilberto Gil"],["Counting Crows"],["Various Artists : The Essential Chill Collection"],["Various Artists : Urban Rai"],["Nelly"],["Various Artists : The Bond James"],["Sia Furler"],["Beethoven"],["Ray Barretto"],["Nofx"],["Luis Resto"],["RJD2"],["Bruce Fowler [Orchestrator]"],["Walt Fowler [Orchestrator]"],["Yvonne S. Moriarty [Orchestrator]"],["Ladd McIntosh [Orchestrator]"],["Elizabeth Finch [Orchestrator]"],["Jack Smalley [Orchestrator]"],["Paris Combo"],["The English Concert [Orchestra]"],["Garou"],["Tenacious D"],["Doe"],["Various Artists : The Best Disco"],["Billy Ze Kick"],["Gentleman"],["The Blues Brothers"],["Yuri Buenaventura"],["Sporto Kantes"],["Ten Years After"],["Pierre Bachelet"],["The Stranglers"],["Various Artists : Pop Ladies"],["New Order"],["alpha 5.20"],["Keny Arkana"],["Antonio Vivaldi"],["Sa\u00efan Supa Crew"],["Various Artists : Les Incontournables Du Zouk"],["Eros Ramazzotti"],["Bliss"],["Justice, Simian"],["Various Artists : Step Up The Streets"],["Luc Plamondon"],["The Ronettes"],["Melvin Charles Bradford"],["Natasha St. Pier"],["Various Artists : Me"],["Yves Larock"],["Robbie Rivera"],["Marie cherrier"],["Julie Zenatti"],["Au Revoir Simone"],["Mathias Malzieu"],["Enigma"],["Skunk Anansie"],["Various Artists : Like"],["Edward Maya, Vika Jigulina"],["Nessbeal"],["Antony & The Johnsons"],["Kate Bush"],["Jean Paul Roy"],["Dj Team"],["Smokey Robinson"],["Thelonious Monk"],["Renaud Sechan"],["Various Artists : Future Trance"],["Andre Young"],["Fleetwood Mac"],["Mos Def"],["Pantera"],["The Academy of St. Martin in the Fields [Orchestra]"],["My Chemical Romance"],["Les Ogres"],["Tom Snare"],["Mano Solo"],["Natalie Imbruglia"],["Collective Soul"],["Fiction Plane"],["Deke Richards"],["Herbert Von Karajan"],["T. Rex"],["INXS"],["Joss Stone"],["The Scorpions"],["Cold War Kids"],["Various Artists, Studio Group"],["Christian Olivier"],["Kid Loco"],["Sinead O Connor"],["Desmond Child"],["Antoine Toustou"],["Various Artists : Bar Lounge Classics"],["Michael Buble"],["Dick Annegarn"],["Various Artists : Juno"],["Various Artists : Annees Classics"],["Michael McKagan"],["Dajla"],["The Raconteurs"],["Sara Bareilles"],["Vivaldi, Antonio"],["Lim"],["Da Silva"],["Jane Birkin"],["Kwal"],["Tori Amos"],["L Zonee"],["Noutz"],["Cake"],["Wax Tailor, Charlotte Savary"],["Youssou N'Dour"],["Buju Banton"],["Lacuna Coil"],["Sanseverino"],["Various Artists : Spirit Of The Ies"],["Zucchero"],["Taylor Swift"],["Erika Nuri"],["David Qui\u00f1ones"],["E Kidd Bogart"],["Rodney \"Darkchild\" Jerkins"],["Shabba Ranks"],["Imogen Heap"],["Ludwig van Beethoven"],["Sukhvinder Singh"],["Son Of Dave"],["Wiener Philharmoniker [Orchestra]"],["The Black Ghosts"],["Imagination"],["The Submarines"],["Ken Boothe"],["Jet"],["Status Quo"],["Geminiani, Francesco"],["Suzanne Vega"],["Jeanne MAS"],["Maniacx"],["Megadeth"],["Percy Sledge"],["Static-X"],["Rhapsody"],["Public Enemy"],["Asian Dub Foundation"],["Various Artists : Les Titres Essentiels Antilles"],["Ewan McGregor"],["Various Artists : Dance Fox Highlights Bootleg"],["Eve"],["Marcel et son Orchestre"],["Various Artists : Grand Theft Auto San Andreas"],["Various Artists : Salsa Around The World"],["Salif"],["James Hetfield"],["Femi Kuti"],["Track Invaders"],["David Hallyday"],["Laurent Garnier"],["The Asteroids Galaxy Tour"],["Barnab\u00e9 Sa\u00efd-Albert"],["Les trois accords"],["Julian Martino"],["Alan Silvestri"],["Various Artists : One Tree Hill"],["Souad Massi"],["David Guetta, Steve Angelo, Cozi"],["Dead Can Dance"],["Oh"],["Atoms"],["Various Artists : Dancefloor Fg Winter"],["Snoop Dogg, Dr. Dre"],["Dusty Springfield"],["Marie Laforet"],["Brasco"],["Various Artists : Ans De Radio Nova"],["Asher Roth"],["Anastacia"],["Dave"],["Avenged Sevenfold"],["Johnny Clarke"],["The Herbaliser"],["Ben Sidran"],["jj cale"],["Blue Foundation"],["Chic"],["Neg' Marrons"],["Boyz II Men"],["Emir Kusturica & The No Smoking Orchestra"],["Andrea Bocelli"],["Don Omar"],["Various Artists : Encyclopedia Of Rock"],["Rick Allison"],["Mozart, Wolfgang Amadeus [Composer]"],["Santa Esmeralda"],["Dizzy Gillespie"],["The Veronicas"],["Midnight Oil"],["Panic! At The Disco"],["Peter Von Poehl"],["Cedric Aiello"],["D.C."],["G\u00e9rard Jouannest"],["Redone"],["Jeffrey Bass"],["Xandria"],["Sharon Jones"],["Fabolous"],["Sebastien Leger"],["Henry Mancini"],["Mr. Oizo"],["La Roux"],["John"],["Murray Head"],["Various Artists : Chess Chartbusters"],["Tok Tok Tok"],["Devendra Banhart"],["Roger Glover"],["Various Artists : Hits Nos"],["Simply Red"],["Andrew White"],["Shawn Carter"],["Freemasons"],["Yvan Cassar"],["The Black Keys"],["Death In Vegas"],["Traditional"],["Collie Buddz"],["Alison Krauss"],["Various Artists : Ministry Of Sound Clubber Guide Summer"],["Various Artists : Ministry Of Sound The Annual"],["A.S.M"],["Bobby Valentino"],["Various Artists : Les Grands Classiques D Edgar"],["Sliimy"],["Ismael Lo"],["Cassius"],["Mylo"],["Bear McCreary"],["Christopher Stewart"],["Israel Vibration"],["The Postal Service"],["Horner"],["David Guetta, El Tocadisco"],["El Tocadisco"],["Ray LaMontagne"],["Melissa Laveaux"],["Various Artists : Chillout Lounge"],["Hittman"],["Various Artists : Best Summer Club Hits"],["Seu Jorge"],["Simon Rix"],["Ricky Wilson"],["Nick Hodgson"],["Kevin Gravier"],["DJ Tiesto"],["Sam & Dave"],["Chubb Rock"],["Various Artists : Top"],["Bonnie Tyler"],["Erwan Roux"],["Steven Marsden"],["Notorious BIG"],["Gojira"],["Hugh Coltman"],["Raggasonic"],["Rob Pattinson"],["G. Baste"],["Atreyu"],["Bost & Bim"],["Herve Roy"],["Jo"],["WAR"],["Lionel Rault"],["Des'ree"],["Brasil '66"],["Obie Trice"],["Dr Meaker"],["Billy Joel"],["Various Artists : The Dark Knight"],["Charlie Parker"],["Lars Ulrich"],["Ana\u00efs Croze"],["Infected Mushroom"],["Francoise Hardy"],["Bj\u00f6rn Ulvaeus"],["Lord Kossity"],["T\u00eates Raides"],["Regina Spektor"],["Calvin Broadus"],["Marina Quaisse"],["AC"],["Gary Moore"],["Hal Mooney"],["Dj Khaled"],["King Tubby"],["The Pogues"],["Sergio Mendes, Brasil '66"],["Bounty Killer"],["Morten Klein"],["Tupac Shakur"],["Gerard Manset"],["Amadou & Mariam"],["Christopher Stills"],["Keren Ann"],["Fat Joe"],["Magic System, Khaled"],["Kronos Quartet"],["Wallen"],["K's Choice"],["The Libertines"],["De-Phazz"],["Passi"],["Various Artists : Saint Germain Des Pres Cafe"],["Nat King Cole"],["Rudy"],["Robert Plant"],["Cheb Mami"],["Elsa"],["John Barry"],["Ja Rule"],["Ice Cube"],["Dinah Washington"],["Cristina Branco"],["Chet Baker"],["Count Basie"],["Faur\u00e9, Gabriel [Composer]"],["Camerata Salzburg [Orchestra]"],["Gerrard, Lisa [Composer\/Author]"],["Amanda Blank"],["Sonata Arctica"],["Beach Boys"],["Various Artists : Grey Anatomy"],["Alizee"],["Village People"],["Peter Bjorn, John"],["richard grey"],["Grace Jones"],["Cazals"],["Jon Bon Jovi"],["Andre Rieu"],["Peter Bjorn"],["Sublime"],["Pixie Lott"],["Gramps Morgan"],["Janet Jackson"],["Europe"],["Plaid"],["Tony Allen"],["Henry Purcell"],["Madhumitha"],["Anis"],["The J.B.'s"],["Lyre le temps"],["Juanes"],["Bitter:Sweet"],["Lil' Kim"],["Cerrone"],["Dirty South"],["Soundgarden"],["Scott Mescudi"],["Will Champion"],["Guy Berryman"],["Zaho"],["Dizzee Rascal"],["Royal Bangs"],["Various Artists : Island Reggae Triple"],["Transbeauce"],["Various Artists, Edward Maya, Vika Jigulina"],["Various Artists : Jazz Lounge"],["Various Artists : Les Plus Belles Chansons De Noel"],["Ma\u00eetrise De La Cath\u00e9drale De Strasbourg"],["Various Artists : Noel En Chansons"],["Josh Groban"],["Various Artists : Vitamine Party"],["Various Artists : Les Petits Chanteurs De La Maitrise Cathedrale Strasbourg Cathedral Children Choirs"],["Tino Rossi"],["Various Artists : Fiesta Fever"],["Bing Crosby"],["Queen Ifrica"],["Gossip"],["Jack Holiday"],["Mike Candys"],["Vybrate"],["Makedah"],["Poker Face Lady Gaga"],["Liberta Pep's"],["Hot N Cold Katy Perry"],["I'm Yours Jason Mraz"],["This Is The Life Amy Macdonald"],["Viva La Vida Coldplay"],["Kids MGMT"],["Boom Boom Pow\nAlbum Version Black Eyed Peas"],["I Hate This Part The Pussycat Dolls"],["After Tonight Justin Nozuka"],["I Kissed A Girl Katy Perry"],["Right Round Flo Rida"],["The Fear Lily Allen"],["Toi + moi Gregoire"],["Decode\nTwilight Soundtrack Version Paramore"],["Walking On A Dream Empire Of The Sun"],["Thriller Michael Jackson"],["I Gotta Feeling\nAlbum Version Black Eyed Peas"],["Comme Des Enfants\nRadio Edit Coeur De Pirate"],["Toi et moi Tryo"],["Just Dance Lady Gaga, Colby O'Donis"],["Right Now (Na Na Na) Akon"],["Elle Panique Olivia Ruiz"],["Addictions Superbus"],["Infinity 2008\nKlaas Vocal Edit Guru Josh Project"],["Womanizer Britney Spears"],["Uprising Muse"],["If I Were A Boy Beyonce"],["So What Pink"],["Like a Hobo Charlie Winston"],["Pour Un Infid\u00e8le Coeur De Pirate, Julien Dor\u00e9"],["Rue Des Etoiles Gr\u00e9goire"],["U-Turn (Lili) Aaron"],["Broken Strings James Morrison, Nelly Furtado"],["Paper Planes Mia"],["Sing For You\nAlbum Version Tracy Chapman"],["Billie Jean Michael Jackson"],["Supermassive Black Hole\nTwilight Soundtrack Version Muse"],["Hallelujah Jeff Buckley"],["Gate 22 Pascale Picard"],["Ayo Technology (Milow cover version) Milow"],["Sober P!nk"],["Beat It Michael Jackson"],["Day 'N' Nite\nCrookers Remix Kid Cudi"],["Cry Cry Oceana"],["Mercy Duffy"],["Fuck You Lily Allen"],["Sunday With A Flu Yodelice"],["The Boy Does Nothing Alesha Dixon"],["Californication Red Hot Chili Peppers"],["Human The Killers"],["Peut-Etre Une Angine Ana\u00efs"],["Sexy Bitch David Guetta, Akon"],["Mr Rock & Roll Amy Macdonald"],["On My Way Cocoon"],["Meet Me Halfway\nAlbum Version Black Eyed Peas"],["Leave Out All The Rest\nTwilight Soundtrack Version Linkin Park"],["Time to Pretend MGMT"],["Disturbia\nAlbum Version Rihanna"],["World go around Busta Rhymes, Estelle"],["Crack A Bottle\nExplicit Version Eminem, Dr. Dre, 50 Cent"],["Paper Planes M.I.A."],["Bohemian Rhapsody Queen"],["I Love Rock and Roll Joan Jett"],["Smooth Criminal Michael Jackson"],["La Nuit Je Mens Alain Bashung"],["Starlight Muse"],["Liberta\nLive A Lyon Pep's"],["Violet Hill Coldplay"],["Putain de toi olivia ruiz"],["C'Est Dit Calogero"],["Shut Up And Let Me Go The Ting Tings"],["Paparazzi Lady Gaga"],["La D\u00e9b\u00e2cle Des Sentiments Calogero, Stanislas"],["LoveGame Lady Gaga"],["C'est Beau La Bourgeoisie Discobitch"],["With Or Without You U2"],["Creep Radiohead"],["Sweet About Me\nRadio Edit Gabriella Cilmi"],["Slow, Slow (Run Run) Ayo"],["Get On Your Boots U2"],["I'll Be Waiting Lenny Kravitz"],["Beggin (Original version) Madcon"],["Love Lockdown Kanye West"],["Life In Technicolor II Coldplay"],["Tell Me It's Not Over Starsailor"],["Bella's Lullaby\nTwilight Soundtrack Version Carter Burwell"],["Sunday Bloody Sunday U2"],["Live your life T.I feat Rihanna"],["Eye of the Tiger Survivor"],["J'Aimerais Tellement Jena Lee"],["Where Is My Mind? The Pixies"],["Seven Nation Army Ben"],["Underground\nAlbum Version (Explicit) Eminem"],["In Your Hands Charlie Winston"],["One 2.3 Four Martin Solveig"],["Fly Away Lenny Kravitz"],["No Stress Laurent Wolf"],["Bleed It Out Linkin Park"],["Under The Bridge Red Hot Chili Peppers"],["When I Grow Up The Pussycat Dolls"],["Lose Yourself Eminem"],["Love Will Tear Us Apart Joy Division"],["I Know You Want Me (calle ocho)\nMore English Radio Edit Pitbull"],["Last Of The English Roses Peter Doherty"],["Hysteria Muse"],["Jai Ho! (You Are My Destiny) A.R. Rahman, The Pussycat Dolls, Nicole Scherzinger"],["Sex On Fire Kings of Leon"],["Jimmy Moriarty"],["L'Effet Papillon Benabar"],["L' Hymne De Nos Campagnes Tryo"],["Dans Ma Rue F\u00e9f\u00e9"],["Mistral gagnant Renaud"],["Can't Stop Red Hot Chili Peppers"],["Resistance Muse"],["Ce que l'on s'aime Tryo"],["Teardrop Massive Attack"],["Stairway To Heaven Led Zeppelin"],["Holiday Green Day"],["Vertige De L'Amour Alain Bashung"],["L'Assasymphonie Mozart Opera Rock"],["Les Limites Julien Dore"],["Numb Linkin Park"],["Paint It Black The Rolling Stones"],["Lucky\nRe-Mastered Version Jason Mraz, Colbie Caillat"],["Rich Girls The Virgins"],["Je te promets Zaho"],["I Caught Myself\nTwilight Soundtrack Version Paramore"],["Sweet Home Alabama Lynyrd Skynyrd"],["Ca Mousse Superbus"],["Rehab\nAlbum Version Rihanna"],["Wish You Were Here Pink Floyd"],["That's Not My Name The Ting Tings"],["harder better faster stronger (alive 2007 extended) Daft Punk"],["The Kids Aren't Alright The Offspring"],["Losing My Religion R.E.M."],["Ta Main Gr\u00e9goire"],["Magnificent U2"],["Hotel California Eagles"],["Seven Nation Army The White Stripes"],["Karma Police Radiohead"],["Single Ladies (Put A Ring On It) Beyonce"],["Evacuate The Dancefloor\nRadio Edit Cascada"],["In The End Linkin Park"],["Undisclosed Desires Muse"],["Chop Suey! System of a Down"],["New Soul Yael Naim"],["Right Here (Departed) Brandy"],["Francis Coeur De Pirate"],["I Got You (I Feel Good) James Brown"],["Lovers In Japan Reign Of Love Coldplay"],["Belle demoiselle Christophe Mae"],["Quelqu'un D'Autre La Grande Sophie"],["Are You Gonna Go My Way Lenny Kravitz"],["I've got that tune Chinese Man"],["We Are Golden MIKA"],["D.A.N.C.E (original) Justice"],["Lisztomania Phoenix"],["Bitter Heart\nAlbum Version Zee Avi"],["Sunburn Muse"],["Bubbly\nAlbum Version Colbie Caillat"],["Supermassive Black Hole Muse"],["G\u00e9n\u00e9ration Virtuelle Olivier Miller"],["Thnks fr th Mmrs\nAlbum Version Fall Out Boy"],["Shadow Of The Day Linkin Park"],["I'm Yours\nAlbum Version Jason Mraz"],["Miss Independent\nAlbum Version Ne-Yo"],["La Lettre Renan Luce"],["Mec A La Cool Manu Larrouy"],["The Scientist Coldplay"],["L'aventurier INDOCHINE"],["Les Voisines Renan Luce"],["I'm All Over It\nAlbum Version Jamie Cullum"],["Give It 2 Me Madonna"],["Zombie\nAlbum Version The Cranberries"],["Otherside Red Hot Chili Peppers"],["Bad Michael Jackson"],["Because Of You Kelly Clarkson"],["The Man Who Can't Be Moved The Script"],["Full Moon\nTwilight Soundtrack Version The Black Ghosts"],["Snow (Hey Oh) Red Hot Chili Peppers"],["One U2"],["La liste Rose"],["You Are Not Alone Michael Jackson"],["Roxanne The Police"],["Release Me\nRadio Edit Agnes"],["Little L Jamiroquai"],["You, Me & The Bourgeoisie The Submarines"],["Baby when the light (with Steve Angelo ft Cozi) David Guetta, Steve Angelo, Cozi"],["Gospel with no Lord Camille"],["Oh! Micky Green"],["21 Guns\nAlbum Version Green Day"],["Back To Black\nClean Version Amy Winehouse"],["Printemps Coeur De Pirate"],["Cry for You September"],["Rehab\nAlbum Version Amy Winehouse"],["Nothing Else Matters Metallica"],["LEAVE! V V Brown"],["Dilly Dally Hakimakli"],["Serre-moi Tryo"],["When I'm Gone Simple Plan"],["Un rayon de soleil William Balde"],["So Fine\nAlbum Version Sean Paul"],["Wild World Cat Stevens"],["L'Homme Press\u00e9 Noir D\u00e9sir"],["Love Is Free\nAlbum Version Sheryl Crow"],["Super Pouvoir d'achat La Chanson Du Dimanche"],["R\u00e9sidents De La R\u00e9publique Alain Bashung"],["Relax, Take It Easy\nAlbum Version MIKA"],["I Don't Care Fall Out Boy"],["No Surprises Radiohead"],["Tired Of Being Sorry Enrique Iglesias"],["C'Est La Vie\nRadio Edit Martin Solveig, Jay Sebag"],["Lady Melody Tom Frager, Gwayav'"],["Mad About You Hooverphonic"],["Harder, Better, Faster, Stronger Daft Punk"],["Some Kinda Rush Booty Luv"],["Tomorrow can wait (vs El Tocadisco) David Guetta, El Tocadisco"],["1234 Feist"],["Mad World Gary Jules"],["Ces Petits Riens Colbie Caillat"],["Lonely Day System of a Down"],["Never Think\nTwilight Soundtrack Version Rob Pattinson"],["Porcelain Moby"],["Around The Bend The Asteroids Galaxy Tour"],["Relator Pete Yorn, Scarlett Johansson"],["Eyes On Fire\nTwilight Soundtrack Version Blue Foundation"],["Killing In The Name Rage Against The Machine"],["Glory Box Portishead"],["Come As You Are\nAlbum Version Nirvana"],["All Along The Watchtower Jimi Hendrix"],["Eh, Eh (Nothing Else I Can Say) Lady Gaga"],["I Want You Back Jackson 5"],["Hey There Delilah Plain White T's"],["4 Minutes (Feat Justin Timberlake and Timbaland) Madonna & Justin Timberlake, Timbaland"],["L\u00e0-bas Jean-Jacques Goldman"],["Dull Life Yeah Yeah Yeahs"],["What I've Done Linkin Park"],["Map Of The Problematique Muse"],["Two Sisters Fiction Plane"],["Zouglou Dance Magic System"],["Take Me Out Franz Ferdinand"],["My Shoes Music Is Not Fun"],["FM Air Zazie"],["Goodbye My Lover James Blunt"],["Light My Fire The Doors"],["Pump It\nAlbum Version Black Eyed Peas"],["Smile Lily Allen"],["Ensemble Coeur De Pirate"],["Still Loving You Scorpions"],["Wind Of Change\nAlbum Version Scorpions"],["Rape Me Nirvana"],["Le Long Du Large Coeur De Pirate"],["La Fille De La Bande Renan Luce"],["Hot Avril Lavigne"],["KM M\u00eame Pas Fatigu\u00e9s Magic System, Khaled"],["Keeps Gettin' Better Christina Aguilera"],["Heart Of Glass Blondie"],["Ecoutez D'O\u00f9 Ma Peine Vient Alain Souchon"],["Stereo Love Various Artists, Edward Maya, Vika Jigulina"],["Desole pour hier soir Tryo"],["Take A Bow\nMain Rihanna"],["Life On Mars? David Bowie"],["Heal The World Michael Jackson"],["C'est chelou Zaho"],["Ulysses - Radio Edit Franz Ferdinand"],["Redemption Song Bob Marley & The Wailers"],["Abbesses Birdy Nam Nam"],["Goodbye Mr A Hoosiers"],["Time Is Running Out Muse"],["Pomme C Calogero"],["Tout Me Revient Marina"],["Hotel Room Service Pitbull"],["Don't Stop 'Til You Get Enough Michael Jackson"],["We Made You\nSingle Version Eminem"],["Tatoue Moi Mozart Opera Rock"],["Boulevard Of Broken Dreams Green Day"],["Cendrillon Telephone"],["Electric Feel MGMT"],["C'Est Dans L'Air Myl\u00e8ne Farmer"],["Heartless\nAlbum Version Kanye West"],["Under Pressure Queen"],["Don't Stop The Music\nAlbum Version Rihanna"],["Smells Like Teen Spirit Nirvana"],["Sultans Of Swing Dire Straits"],["Imagine One Day Grace"],["Breathe Me Sia"],["Let It Rock\nAlbum Version Kevin Rudolf, Lil Wayne"],["I'm Throwing My Arms Around Paris\nMix 4 Morrissey"],["Wow Kylie Minogue"],["Black or White Michael Jackson"],["You're Gonna Go Far, Kid The Offspring"],["London Calling The Clash"],["M\u00e9lodie Pep's"],["Buffalo Soldier Bob Marley"],["You'll Find A Way Santogold"],["Airport Surroundings Loney, Dear"],["Hit The Road Jack Ray Charles"],["Berceuse Coeur De Pirate"],["I Want You Martin Solveig"],["Tous Les Cris Les S.O.S.\nAlbum Version Daniel Balavoine"],["The Passenger Iggy Pop"],["Osez Jos\u00e9phine Alain Bashung"],["Song 2 Blur"],["Balulalow Revolver."],["Get Around Town Revolver"],["Iron Lion Zion Bob Marley"],["Chupee cocoon"],["C'\u00e9tait Salement Romantique Coeur De Pirate"],["How To Save A Life The Fray"],["Rain MIKA"],["Kashmir Led Zeppelin"],["Bernard Lavilliers Fatals Picards"],["J'ai Demand\u00e9 \u00e0 la Lune INDOCHINE"],["You're Beautiful James Blunt"],["Banquet Bloc Party"],["Unintended Muse"],["Basket Case Green Day"],["La Grange ZZ Top"],["Flightless Bird, American Mouth\nTwilight Soundtrack Version Iron & Wine"],["J'T'Emm\u00e8ne Au Vent\nAlbum Version Louise Attaque"],["I Want To Break Free Queen"],["Carry You Home James Blunt"],["Sweet Child O' Mine\nAlbum Version Guns N' Roses"],["Feeling Good Muse"],["Should I Stay Or Should I Go The Clash"],["Tonight\nRadio Edit Yuksek"],["Thinking of You Katy Perry"],["Love love love James Blunt"],["Are You Gonna Be My Girl Jet"],["Appelle Mon Num\u00e9ro Myl\u00e8ne Farmer"],["We Will Rock You Queen"],["My Heart Will Go On Celine Dion"],["L.E.S Artistes Santogold"],["Tant De Nuits Alain Bashung"],["Summertime Janis Joplin"],["Gives You Hell\nAlbum Version The All-American Rejects"],["Molotov 4 SEFYU"],["Requiem for a Dream (Orchestral Version) Clint Mansell"],["Muscle Museum Muse"],["S.O.S.\nAlbum Version Jonas Brothers"],["Si Tu N'Etais Plus L\u00e0 Sheryfa Luna"],["United States Of Eurasia (+Collateral Damage) Muse"],["La Superbe Benjamin Biolay"],["In Too Deep Sum 41"],["Playground Love Air"],["Ooh Yeah Moby"],["Low Flo Rida, T-Pain"],["Tremble For My Beloved\nTwilight Soundtrack Version Collective Soul"],["Spotlight MuteMath"],["Lemon Tree Fool's Garden"],["Le Vent Nous Portera\nAlbum Version Noir D\u00e9sir"],["Cola Bottle Baby Edwin Birdsong"],["Black Dog Led Zeppelin"],["Everybody Hurts R.E.M."],["Somewhere Over The Rainbow & Israel Kamakawiwo'ole"],["Toxicity System of a Down"],["A la faveur de l'automne T\u00e9t\u00e9"],["Un Jour En France Noir D\u00e9sir"],["Somebody Told Me The Killers"],["I Was Made For Lovin' You Kiss"],["In My Arms Kylie Minogue"],["Another Day Jamie Lidell"],["By The Way Red Hot Chili Peppers"],["Dream On Aerosmith"],["In My Place Coldplay"],["Smoke On The Water Deep Purple"],["Now You're Gone BassHunter"],["(If You're Wondering If I Want You To) I Want You To Weezer"],["Le Roi Des Ombres M"],["decale gwanda Jessy Matador"],["Beds Are Burning Midnight Oil"],["Hung Up Madonna"],["Boys Don't Cry The Cure"],["One in a million\nDrixxx\u00e9 Remix DatA"],["Leave Out All The Rest Linkin Park"],["Delirious (ft Tara Mc Donald) David Guetta, Tara Mc Donald"],["I Will Always Love You Whitney Houston"],["Sympathy For The Devil The Rolling Stones"],["Walk On By\nAlbum Version Diana Krall"],["Love Is Wicked\nAlbum Version Brick & Lace"],["Lebanese Blonde Thievery Corporation"],["Rockstar Nickelback"],["Beat It\nStudio Version Fall Out Boy, John Mayer"],["My Favourite Game The Cardigans"],["Double Je Christophe Willem"],["3 Nuits Par Semaine INDOCHINE"],["Lovefool\nRadio Edit The Cardigans"],["Dirty Diana Michael Jackson"],["Je marche seul Jean-Jacques Goldman"],["Enjoy The Silence Depeche Mode"],["Angel Massive Attack"],["L'amour \u00e0 la fran\u00e7aise Fatals Picards"],["Clocks Coldplay"],["Don't Worry, Be Happy Bob Marley"],["Elle a les yeux revolver Marc Lavoine"],["Golden Brown The Stranglers"],["Stayin' Alive Bee Gees"],["Beautiful Emilie Keziah Jones"],["Hey You Pink Floyd"],["The Way Junior Caldera"],["Angie\n2009 Re-Mastered Digital Version The Rolling Stones"],["Kill! Kill! Kill! The Pierces"],["Purple Rain Prince"],["Rock This Party Bob Sinclar"],["Sweetest Girl (Dollar Bill) (Feat. Akon, Lil Wayne And Introducing Niia) Wyclef Jean, Akon, Lil Wayne, Introducing Niia"],["Allo Le Monde (Version Radio) Pauline"],["White Flag Dido"],["Ne Me Quitte Pas\nAlbum Version Jacques Brel"],["Earth Song Michael Jackson"],["Foundations Kate Nash"],["Sittin' on the Dock of the Bay Otis Redding"],["Pure Morning Placebo"],["Down On My Knees Ayo"],["Je Veux Tout Ariane Moffatt"],["Whistle Sporto Kantes"],["Love Is Gone David Guetta"],["Lollipop\nMain Lil Wayne, Static Major"],["On My Shoulders The Do"],["Use Somebody Kings of Leon"],["On S'Fait Du Mal\nVersion Single Makali"],["Sun Goes Down David Jordan"],["American Boy Estelle Ft. Kanye"],["Je Suis Un Homme Zazie"],["If I Ever Feel Better Phoenix"],["How You Remind Me Nickelback"],["Crushcrushcrush Paramore"],["Kick the Bucket Charlie Winston"],["J'Aime Plus Paris Thomas Dutronc"],["Fondu Au Noir Coeur De Pirate"],["The Rip Portishead"],["Takin' Back My Love Enrique Iglesias, Ciara"],["La Boheme Charles Aznavour"],["Out Dance (Feat. Charlotte Savary) Wax Tailor, Charlotte Savary"],["Lucky\nAlbum Version Jason Mraz, Colbie Caillat"],["The Reason\nAlbum Version Hoobastank"],["Feel Good Inc. Gorillaz"],["Give It Away Red Hot Chili Peppers"],["Gad Zawajouni Various Artists : D Une Seule Voix"],["Ca (C'est Vraiment Toi) Telephone"],["Good Vibrations The Beach Boys"],["Kiss Kiss (Feat. T-Pain) Chris Brown, T-Pain"],["Comptine D'un Autre \u00c9t\u00e9: L'apr\u00e8s Midi Yann Tiersen"],["Je l'aime \u00e0 mourir Francis Cabrel"],["Intermission Coeur De Pirate"],["Feeling Good (From \"The Roar Of The Greasepaint\")\nAlbum Version Nina Simone"],["Jeune Et Con\nAlbum Version Saez"],["Je Suis Venu Te Dire Que Je M'En Vais\nAlbum Version Serge Gainsbourg"],["The Show Must Go On Queen"],["The Man With The Red Face Laurent Garnier"],["Ton Invitation\nSingle Version Louise Attaque"],["Bitter Sweet Symphony The Verve"],["La Vie Est Ailleurs Coeur De Pirate"],["With You Chris Brown"],["Knights Of Cydonia Muse"],["Canned Heat Jamiroquai"],["You Rock My World Michael Jackson"],["Break On Through The Doors"],["Clubbed to Death Rob Dougan"],["Show Me Love Michael Mind"],["Manu Renaud"],["No Woman No Cry Bob Marley"],["Gimme More Britney Spears"],["The End The Doors"],["Fortunate Son\nAlbum Version Creedence Clearwater Revival, John Fogerty"],["Come Out and Play The Offspring"],["Si tu savais Shy'm"],["My Immortal (Band Version) Evanescence"],["Anyone Else But You The Moldy Peaches"],["Butterfly Superbus"],["Gold Antoine Clamaran"],["Ca M'Enerve Helmut Fritz"],["Dead And Gone [feat. Justin Timberlake]\nExplicit Album Version T.I., Justin Timberlake"],["Gimme! Gimme! Gimme! (A Man After Midnight) ABBA"],["Mais Que Nada\nAlbum Version Sergio Mendes, Brasil '66"],["Sometimes WAX TAILOR"],["Qui de nous deux M"],["Good People Jack Johnson"],["D\u00e9g\u00e9n\u00e9ration Myl\u00e8ne Farmer"],["Just Can't Get Enough Depeche Mode"],["Wash my world Laurent Wolf"],["Somewhere Only We Know Keane"],["The Logical Song Supertramp"],["The Light Izia"],["Could You Be Loved\nAlbum Version Bob Marley & The Wailers"],["Please Don't Leave Me Pink"],["Monp'tit gars Christophe Mae"],["You Know I'm No Good Amy Winehouse"],["Kiss From A Rose Seal"],["All Day And All Of The Night The Kinks"],["La Main Verte Tryo"],["Technologic Daft Punk"],["Petite Marie Francis Cabrel"],["Hexagone Renaud"],["Kif'n'dir Zaho"],["Streets of Philadelphia bruce springsteen"],["God Save the Queen Sex Pistols"],["Les Lacs Du Connemara\nAlbum Version Michel Sardou"],["Never Miss A Beat Kaiser Chiefs"],["Warwick Avenue Duffy"],["Hey Jude\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Je Veux \u00catre Une Star (3\u00e8me Tentative) Didier Super"],["War Bells Royal Bangs"],["Russian Roulette\nAlbum Version Rihanna"],["Xd7 Transbeauce"],["Bad Romance Lady Gaga"],["Stereo Love\nRadio Edit Edward Maya, Vika Jigulina"],["Il Y A Vanessa Paradis"],["She Wolf\nAlbum Version Shakira"],["Big orgus DJ Furax, Red Shark"],["When Love Takes Over David Guetta"],["I Gotta Feeling\nEdit Black Eyed Peas"],["Summer 78 Yann Tiersen"],["Drive My Car\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Au Bord De L'Eau G\u00e9rald De Palmas"],["Je R\u00eave\nIn\u00e9dit Gr\u00e9gory Lemarchal"],["Lady Melody Tom Frager"],["Unnatural Selection Muse"],["Another Brick In The Wall Pink Floyd"],["Sinnerman (Felix Da Housecat's Heavenly House Mix) Nina Simone"],["Funhouse Pink"],["Adore I:Cube"],["La Fin De La Fin Du Monde Calogero"],["Money David Guetta"],["Moskau Rammstein"],["Smells Like Teen Spirit\nAlbum Version Nirvana"],["Mk Ultra Muse"],["Insomnia\nRadio Edit Mike Candys, Jack Holiday"],["Miss France Helmut Fritz"],["\u00e7a m'\u00e9nerve Helmut Fritz"],["Heavy Cross (as made famous by The Gossip) Future Hit Makers"],["Run This Town (Featuring Rihanna And Kanye West) Jay-Z, Rihanna, Kanye West"],["Petit Papa No\u00ebl Tino Rossi"],["I Belong To You (+Mon Coeur S'ouvre A Ta Voix) Muse"],["Summer Son\nAlbum Version Texas"],["Celebration Madonna"],["On And On\nRadio Edit Agnes"],["Still D.R.E.\nAlbum Version (Explicit) Dr. Dre, Snoop Dogg"],["Avril 14th Aphex Twin"],["Emmenez-Moi Vanessa Paradis"],["D\u00e8s Que J'Te Vois Vanessa Paradis"],["Jet\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Joe Le Taxi\nAlbum Version Vanessa Paradis"],["Guiding Light Muse"],["Organ Donor\nExtended Overhaul DJ Shadow"],["Empire State Of Mind (Featuring Alicia Keys) Jay-Z, Alicia Keys"],["Rock That Body\nAlbum Version Black Eyed Peas"],["New Divide\nAlbum Version Linkin Park"],["Come On\nRadio Edit Javi Mula"],["Elenore The Turtles"],["Vois Sur Ton Chemin Didier Super"],["Exogenesis : Symphony Part I (Overture) Muse"],["Bulletproof La Roux"],["Sunny Afternoon The Kinks"],["Shut it down feat. Akon Pitbull"],["Hey Ya! OutKast"],["In The Waiting Line Zero 7"],["Let It Be\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Amsterdam Jacques Brel"],["Jumpin' Jack Flash The Rolling Stones"],["Stupid Girl Garbage"],["Bring Me To Life Evanescence"],["Vivre a en crever Mozart Opera Rock"],["So Easy R\u00f6yksopp"],["Natural Mystic Bob Marley"],["Shine On You Crazy Diamond Pink Floyd"],["Tandem\nAlbum Version Vanessa Paradis"],["Weird Love Moodorama"],["Musical Bonzeye High Tone"],["Dans Une Larme G\u00e9rald De Palmas"],["Woman Neneh Cherry"],["Le Bien qui fait mal Mozart Opera Rock"],["Sunny Bobby Hebb"],["What You Get\nOriginal Radio Long Edit Junior Caldera"],["D\u00e8s que le vent soufflera Renaud"],["L'Ombre Et La Lumi\u00e8re Calogero, Grand Corps Malade"],["Party In The U.S.A. Miley Cyrus"],["Dark Lady DJ Food"],["Rue de panam Les Ogres de Barback"],["Un autre monde Telephone"],["Welcome To My Life Simple Plan"],["Immigrant Song Led Zeppelin"],["Couleur Menthe A L'Eau\nAlbum Version Eddy Mitchell"],["Feel Robbie Williams"],["Umbrella\nAlbum Version Rihanna"],["Pourtant\nAlbum Version Vanessa Paradis"],["Tout le bonheur du monde SINSEMILIA"],["Neon Music REMIX 2009 by Soundshakerz Radio Edit\nSoundshakerz Radio Edit BIG ALI"],["Divine Idylle Vanessa Paradis"],["Ma Benz NTM"],["This Ain't A Scene, It's An Arms Race Fall Out Boy"],["Amerika Rammstein"],["Hey Jude The Beatles"],["Slow Down Morcheeba"],["High Hopes Pink Floyd"],["Another Day in Paradise Phil Collins"],["Four To The Floor Starsailor"],["Lullaby\nFear Of Fours Album Version Lamb"],["La groupie du pianiste Michel Berger"],["(I Can't Get No) Satisfaction The Rolling Stones"],["L'Incendie Vanessa Paradis"],["Reviens Mon Amour Marc Lavoine"],["Only Mama Knows\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Your Kisses Are Wasted On Me The Pipettes"],["Nantes Beirut"],["Headspace Archive"],["Paranoid Android Radiohead"],["Message In A Bottle The Police"],["Comme Un Enfant Au Br\u00e9sil Didier Super"],["Can't Get You Out Of My Head Kylie Minogue"],["Got It Going On (Aim Remix) Deadbeats"],["Dis Lui Toi Que Je T'Aime\nAlbum Version Vanessa Paradis"],["They Don't Care About Us Michael Jackson"],["22 Lily Allen"],["Passing By Zero 7"],["Friday On My Mind Easybeats"],["Lovers Rock sade"],["Shut Up\nAlbum Version Black Eyed Peas"],["La Diff\u00e9rence Salif Keita"],["Marilyn & John Vanessa Paradis"],["Wherever You Will Go The Calling"],["Dirty Harry Gorillaz"],["What A Wonderful World Louis Armstrong"],["Fallin' Alicia Keys"],["I love you (Late Night Mix) Blank & Jones"],["Karma Coma Massive Attack, Tricky"],["A Girl Like You Edwyn Collins"],["L'Envie Johnny Hallyday"],["Back In The USSR\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Mad House\nAlbum Version Rihanna"],["Je Te Promets Johnny Hallyday"],["Imagine John Lennon"],["Hush Hush; Hush Hush\nAlbum Version The Pussycat Dolls"],["We Used To Be Friends The Dandy Warhols"],["Happiness De-Phazz"],["Marche A L'Ombre Renaud"],["Divenire Ludovico Einaudi"],["Say Aha Santogold"],["Some People (Ton D\u00e9sir) Ocean Drive, DJ Oriska"],["Who'S In The House\nNew Vocal Edit Chris Kaeser"],["Fireflies\nAlbum Version Owl City"],["Mongrel... DJ Shadow"],["La Semaine Prochaine Marc Lavoine"],["Born To Be Alive Patrick Hernandez"],["Sunny Boney M."],["Aerodynamic Daft Punk"],["Onde sensuelle M"],["The Letter The Box Tops"],["Imma Be\nAlbum Version Black Eyed Peas"],["Eyen Plaid"],["Almarita La Rue K\u00e9tanou"],["Deify Disturbed"],["Mrs. Vandebilt\nLive at CitiField, NYC - Digital Audio Paul McCartney"],["Two Princes Spin Doctors"],["Ketto Bonobo"],["Tick Tick Boom\nAlbum Version The Hives"],["Rape Me\nAlbum Version Nirvana"],["She's A Rainbow\nStereo Edit Version \/ Without Intro The Rolling Stones"],["Bang Bang (My Baby Shot Me Down) Nancy Sinatra"],["Bohemian Like You The Dandy Warhols"],["Brighton Beach T\u00e9l\u00e9popmusik"],["Fake It Seether"],["Seashell Skylab"],["Petit Cheminot La Chanson Du Dimanche"],["Exogenesis : Symphony Part II (Cross Pollination) Muse"],["If I Ruled The World\nAlbum Version Jamie Cullum"],["Couleur Caf\u00e9\nAlbum Version Serge Gainsbourg"],["Black Hole Sun Soundgarden"],["Quelques mots d'amour Michel Berger"],["Le Poin\u00e7onneur Des Lilas Serge Gainsbourg"],["You Really Got Me The Kinks"],["Eve, leve toi Julie Pietri"],["If It Makes You Happy Sheryl Crow"],["Cry Baby Spiller"],["Peacock Tail Boards of Canada"],["Bad Boys Inner Circle"],["Hopscotch\nAlbum Version Howie B."],["It's My Life\nAlbum Version Bon Jovi"],["Jocelyne Tryo"],["Don't Stop The Music\nAlbum Version Jamie Cullum"],["Through the Backyards Au Revoir Simone"],["Closer to me (with Elles) Blank & Jones, Elles"],["Rebel Rebel David Bowie"],["Get Back To Serenity (Beach Mix) Vargo"],["One More Time Daft Punk"],["NRJ Music Awards 2009 Various Artists : Nrj Music Awards"],["Hits Attitude Various Artists : Hits Attitude"],["Balance Le Son Various Artists : Balance Le Son"],["M6 Hits 2009 Various Artists : M Hits"],["Music From The Original Motion Picture Soundtrack\nInternational Version Various Artists : Music From The Original Motion Picture International"],["The Fame\nInternational Version Lady GaGa"],["The Fame\nRevised International Version Lady GaGa"],["Coeur De Pirate Coeur De Pirate"],["Woman To Woman\nInternational Version Various Artists : Woman To International"],["One of the Boys Katy Perry"],["Toi + Moi Gregoire"],["NRJ Hit List Various Artists : Nrj Hit List"],["This is the Life\nSpecial Edition Amy Macdonald"],["NRJ 200% Hits\n2009 Various Artists : Nrj Hits"],["Viva La Vida or Death and All His Friends Coldplay"],["THE E.N.D. (THE ENERGY NEVER DIES)\nInternational Version Black Eyed Peas"],["This Is The Life\nFrench Version Amy Macdonald"],["It's Not Me It's You Lily Allen"],["Triple Best Of Les Plus Belles Chansons Francaises 1980-2000 Various Artists : Triple Les Plus Belles Chansons Francaises"],["Un Diner Presque Parfait Various Artists : Un Diner Presque Parfait"],["Good Morning England\nStandard E Album Various Artists : Good Morning England Standard E"],["Ce que l'on s\u00e8me Tryo"],["The Resistance Muse"],["Oracular Spectacular MGMT"],["Doll Domination - The Mini Collection\nUK Version The Pussycat Dolls"],["HIStory: Past, Present and Future, Book 1 (disc 1: HIStory Begins) Michael Jackson"],["100 Essential Love Songs Various Artists : Essential Love Songs"],["Fatal Hits Various Artists : Fatal Hits"],["Poker Face\nFrance Version Lady GaGa"],["Poker Face Lady GaGa"],["Doll Domination\nInternational Deluxe Version The Pussycat Dolls"],["Doll Domination\nInternational Version The Pussycat Dolls"],["We Sing. We Dance. We Steal Things.\nInternational Jason Mraz"],["Motown 50\nInternational Version Various Artists : Motown International"],["Vol. 1-Greatest Hits History Michael Jackson"],["Ultimate R&B 2008 (Double Album)\nInternational Version Multi Interpr\u00e8tes"],["Number Ones Michael Jackson"],["Our Bright Future Tracy Chapman"],["Triple Best Of Les Intemporelles De La Chanson Fran\u00e7aise 1950-1970 Various Artists : Triple Les Intemporelles De La Chanson Francaise"],["Ultimate R&B Love 2008 Various Artists : Ultimate R B Love"],["De Gainsbourg A Gainsbarre Serge Gainsbourg"],["Greatest Hits Red Hot Chili Peppers"],["Zest Of Zazie"],["The Essential Michael Jackson (disc 2) Michael Jackson"],["Not Guilty (Special Fan Edition) Michael Jackson"],["No Line On The Horizon\nInternational Version U2"],["Slumdog Millionaire - Music From The Motion Picture\nInternational Billing Block version Various Artists : Slumdog Millionaire"],["Master Serie CD Renaud"],["MEGA 80 Various Artists : Mega"],["Quand On N'a Que L'Amour Jacques Brel"],["Les 50 Plus Belles Chansons Bob Marley"],["Europe 1 L'Album Various Artists : Europe L"],["Gainsbourg For Ever Serge Gainsbourg"],["Mothership Led Zeppelin"],["Relapse\nExplicit Version Eminem"],["Miss M\u00e9t\u00e9ores olivia ruiz"],["Hobo Charlie Winston"],["Promo Only: Mainstream Radio, June 2008 Various Artists : Promo Only Mainstream Radio"],["Starfloor Various Artists : Starfloor"],["This Is The Life\nFrench Wallet version Amy Macdonald"],["Point De Suture Myl\u00e8ne Farmer"],["Infiniment Jacques Brel"],["Tubes RTL 2009 Various Artists : Tubes Rtl"],["Wordplay Jason Mraz"],["Utopies Dans Le D\u00e9cor Pep's"],["Greatest Hits Queen"],["Music of the Millennium (disc 1) Radiohead"],["Greatest Hits Lenny Kravitz"],["Climax Alain Bashung"],["Rockferry\nintl Deluxe Edition Duffy"],["Minutes To Midnight\nExplicit Version Linkin Park"],["L'Embellie Calogero"],["I Hate This Part\nInternational Version The Pussycat Dolls"],["Les 50 Plus Belles Chansons Daniel Balavoine"],["The Boy Who Knew Too Much\nInternational Standard Version Mika"],["Boom Boom Pow Black Eyed Peas"],["Absolution Muse"],["Renaud Renaud"],["Grain de sable Tryo"],["The Platinum Collection (disc 1: Greatest Hits I) Queen"],["Red Hot Chilli Peppers Greatest Hits Red Hot Chili Peppers"],["R.O.O.T.S Flo-Rida"],["Holly Justin Nozuka"],["La Caravane Des Enfoir\u00e9s Les Enfoires"],["Greatest Hits I & II (disc 1) Queen"],["Tree Of Life Yodelice"],["Sans Fronti\u00e8res Daniel Balavoine"],["Rockferry Duffy"],["The Meilleur Of Renaud Renaud"],["Songs For You, Truths For Me\nUS iTunes Version James Morrison"],["Songs For You, Truths For Me\nEU Version James Morrison"],["C'Est La Vie Martin Solveig"],["Woman Various Artists : Woman"],["Right Round Flo-Rida"],["Meteora Linkin Park"],["Louise Attaque Louise Attaque"],["Pamplemousse M\u00e9canique\nEdition Eurovision + 1 titre bonus Fatals Picards"],["The Ultimate Collection (disc 3) Michael Jackson"],["Discovery Daft Punk"],["Contact Play & Dance 2009 Various Artists : Contact Play Dance"],["The Best of The Doors The Doors"],["Hip Hop 2009 Various Artists : Hip Hop"],["Greatest Hits: History, Volume 1 Michael Jackson"],["Mamagubida Tryo"],["Anthologie Johnny Hallyday"],["Jacques Brel Jacques Brel"],["Master S\u00e9rie Daniel Balavoine"],["Quinze Ans D'Amour Jacques Brel"],["Good Morning England (The Boat That Rocked)\nStandard E Album Various Artists : Good Morning England"],["Only By The Night Kings of Leon"],["Daniel Balavoine \/ Balavoine Daniel Balavoine"],["Triple Best Of Johnny Hallyday"],["Good Girl Gone Bad: Reloaded Rihanna"],["Back To Black Amy Winehouse"],["Talents Vol 1 Renaud"],["Master S\u00e9rie Renaud"],["Talents Du Siecle Volume 1 Renaud"],["20 Chansons D'or Charles Aznavour"],["Gravity At Last Ayo"],["Starfloor 6 Various Artists : Starfloor"],["Bleu P\u00e9trole Alain Bashung"],["Life In Cartoon Motion Mika"],["Gee whiz but this is a Lonesome Town Moriarty"],["Greatest Hits I & II (disc 2) Queen"],["Best Of The Cardigans"],["Just Dance\nFrench Version Lady GaGa"],["Good Girl Gone Bad Rihanna"],["Top Gear Anthems Various Artists : Top Gear Anthems"],["OK Computer Radiohead"],["Showbiz Muse"],["Wow Superbus"],["Sex And The City - Original Motion Picture Soundtrack Various Artists : Sex And The City"],["Treasure Box : The Complete Sessions 1991-99 The Cranberries"],["Ersatz Julien Dore"],["Ma Compil Various Artists : Ma"],["The World's Greatest (disc 2) Michael Jackson"],["Comme Des Enfants Coeur De Pirate"],["Legend Bob Marley & The Wailers"],["Greatest Hits Guns N' Roses"],["Instrumental Version Collection Michael Jackson"],["Love Supply Oceana"],["Long Box Michel Sardou"],["Supertramp - The Very Best Of Supertramp"],["Grand Collection The Doors"],["Nevermind Nirvana"],["Sultans Of Swing - The Very Best Of Dire Straits Dire Straits"],["Americana The Offspring"],["Generation Mondotek 2 Various Artists : Generation Mondotek"],["Anthologie 3 Johnny Hallyday"],["808s & Heartbreak\nSoftpak Kanye West"],["Master Serie Jacques Brel"],["The 50 Greatest Songs Jackson 5"],["Just Dance\nInternational Version Lady GaGa"],["Talents Vol 1 Jacques Brel"],["Right Now (Na Na Na)\nInt'l 2Trk Akon"],["Elle Panique olivia ruiz"],["Legacy: The Absolute Best (disc 1) The Doors"],["The Love Album\nWith PDF Booklet Ana\u00efs"],["Triple Best Of Florent Pagny"],["Mozart l'Opera Rock\nstandard Mozart Opera Rock"],["20th Century Masters: The Millennium Collection: Best Of Scorpions Scorpions"],["Africa Unite: The Singles Collection Bob Marley & The Wailers"],["666.667 Club Noir D"],["Fallen Evanescence"],["Thriller: 25th Anniversary Edition Michael Jackson"],["Le Fabuleux Destin d'Am\u00e9lie Poulain Yann Tiersen"],["Grace Jeff Buckley"],["Je vais bien, ne t'en fais pas\nOriginal Motion Picture Soundtrack Various Artists : Je Vais Bien"],["German Top100 Single Charts Various Artists : German Top Single Charts"],["One Love: The Very Best Of Bob Marley"],["Sing For You Tracy Chapman"],["The Groove Sessions Chinese Man"],["Gold The Cranberries"],["Zee Avi Zee Avi"],["My One And Only Thrill Melody Gardot"],["Greatest Hits II Queen"],["Grace\/Wastelands Peter Doherty"],["The Very Best of The Doors The Doors"],["The Doors The Doors"],["All The Lost Souls\nIntl Audio Deluxe Version James Blunt"],["The Complete Studio Recordings (disc 1: The Doors) The Doors"],["It Is Time for a Love Revolution Lenny Kravitz"],["Des roses & des orties Francis Cabrel"],["Broken Strings\nInternational Maxi Single James Morrison"],["Pure Chillout (disc 2) Various Artists : Pure Chillout"],["Talents Du Si\u00e8cle Volume 2 Daniel Balavoine"],["Talents Vol 1 Daniel Balavoine"],["Dancefloor Fg Summer 2008 Various Artists : Dancefloor Fg Summer"],["Broken Strings\nInternational E-Single James Morrison"],["Des Vagues Et Des Ruisseaux\nVersion Standard La Grande Sophie"],["Day & Age The Killers"],["Mr Rock N Roll Amy Macdonald"],["Broken Strings\nInternational CD Single James Morrison"],["Hypnotize System of a Down"],["Fantaisie Militaire Alain Bashung"],["La Grand-Messe Les cowboys fringants"],["Stars: The Best Of The Cranberries 1992-2002 The Cranberries"],["Old Skool Of Rock Various Artists : Old Skool Of Rock"],["Led Zeppelin IV Led Zeppelin"],["In Between Dreams Jack Johnson"],["Pop Life David Guetta"],["Blood Sugar Sex Magik Red Hot Chili Peppers"],["Nirvana Nirvana"],["Soul Wash Ben"],["Dummy Portishead"],["Stadium Arcadium Red Hot Chili Peppers"],["\u767d\u7fbd\u6bdb\u4e4b\u6200 Madonna"],["Bob Marley Bob Marley"],["Kala Mia"],["MS Michel Sardou"],["The Very Best of Otis Redding Otis Redding"],["Les 50 Plus Belles Chansons De Florent Pagny Florent Pagny"],["History Michael Jackson"],["The Very Best Of Smooth Jazz Various Artists : The Very Smooth Jazz"],["50 Jahre Bravo: 1956 - 2006 (disc 2) Anastacia"],["Mezmerize System of a Down"],["Ballades Et Mots D'Amour Jacques Brel"],["The Pursuit Jamie Cullum"],["Snatch 10cc"],["Legend Bob Marley"],["The Very Best Of Cat Stevens Cat Stevens"],["Back to Bedlam James Blunt"],["Birdy Nam Nam Birdy Nam Nam"],["Billy Jean Michael Jackson"],["The Very Best Of... Michael Jackson"],["Mobile Beat Dance Various Artists : Mobile Beat Dance"],["BMI 50th Anniversary-Disc 2 Of 3 Various Artists : Bmi Th Of"],["KO Hits #014 ERG"],["Mobile Beat #1 Various Artists : Mobile Beat"],["DJ Tools Volume 7 DJ Tools Volume 7"],["Hollywood Planet Rock 2 Various Artists : Hollywood Planet Rock"],["30 Platinum Series (Disc 30) Various Artists : Platinum Series"],["The Essential Michael Jackson [Disc 1] Michael Jackson"],["Number Ones [Europe] Michael Jackson"],["Forever Gold [Disc 1] Various Artists : Forever Gold"],["Thriller 25 Michael Jackson"],["American Top40's 20th Anniversary With Shadow Stevens Various Artists : American Top Th With Shadow Stevens"],["Los Grandesn Exitos Michael Jackson"],["The Best of Songs Michael Jackson"],["Radio Essential Series 17 Promo Only Canada"],["Pop Music: The Modern Era 1976-1999 [Disc 1] Various Artists : Pop Music The Modern Era"],["Greatest Karaoke Hits (disc 1) Queen"],["We Started Nothing The Ting Tings"],["Soul Seal"],["Am\u00e9lie Yann Tiersen"],["Die fabelhafte Welt der Amelie Yann Tiersen"],["The Boy Who Knew Too Much\nInternational Special Edition Album - AOBP Mika"],["Snatch: Stealin' Stones & Breakin' Bones Various Artists : Snatch Stealing Stones Breaking Bones"],["2 CD Master S\u00e9rie Georges Brassens"],["Ayo Technology - Single Milow"],["Hybrid Theory Linkin Park"],["Les 50 Plus Belles Ballades De Johnny Hallyday Johnny Hallyday"],["Hot Rocks 1964-1971 (disc 1) The Rolling Stones"],["l'\u00e9cole du micro d'argent+10 titres inedits - full album 2 Cd serie limit\u00e9e IAM"],["21st Century Breakdown Green Day"],["The Best of Dire Straits & Mark Knopfler - Private Investigations Dire Straits"],["Into the Wild Eddie Vedder"],["Live Magic Queen"],["The Best Anthems... Ever! (disc 1) The Chemical Brothers"],["L'Essentiel Daniel Balavoine"],["Remember Cat Stevens - The Ultimate Collection Cat Stevens"],["Bad For Good: The Very Best Of Scorpions Scorpions"],["Cembalokonzerte, BWV 1052-1055 Johann Sebastian Bach"],["Monkey Business Black Eyed Peas"],["American Idiot Green Day"],["Prospekt's March Coldplay"],["Complete Clapton Eric Clapton"],["Bundle 5 Titres La Chanson Du Dimanche"],["100 Classical Favourites Mendelssohn, Felix [Composer]"],["100 Classic French Songs Various Artists : Classic French Songs"],["JIWA 24 Hours Party Mix by Repie FP Uto Karem"],["Dangerous Michael Jackson"],["Classic Queen Queen"],["Dreams to Remember (The Very Best of Otis Redding) Otis Redding"],["5 Lenny Kravitz"],["Physical Rarities Led Zeppelin"],["Anthology: Jackson 5 Jackson 5"],["Hope & Sorrow WAX TAILOR"],["Jeune A La Retraite F\u00e9f\u00e9"],["The Essential Michael Jackson (disc 1) Michael Jackson"],["Fg Club Dance 2009 Various Artists : Fg Club Dance"],["Album Standard Mozart Opera Rock"],["In Rainbows Radiohead"],["The Ultimate Collection: Jackson 5 Jackson 5"],["Best of Queen Queen"],["L'Equilibre Instable Stanislas"],["Triple J Hottest 100, Volume 1 (disc 1) Various Artists : Triple J Hottest"],["Rage Against the Machine Rage Against The Machine"],["A Rush of Blood to the Head Coldplay"],["The Best of the Doors (disc 1) The Doors"],["Highest Hopes-The Best Of Nightwish Nightwish"],["Santogold Santogold"],["Greatest Hits The Offspring"],["Folk & Proud Various Artists : Folk Proud"],["Year Of The Gentleman Ne-Yo"],["Sunday With the Flu Yodelice"],["Demon Days Gorillaz"],["Infr\u00e9quentable Benabar"],["No Need To Argue (The Complete Sessions 1994-1995) The Cranberries"],["Rose Rose"],["Motown Love\nInternational Version Various Artists : Motown Love International"],["The Albums ABBA"],["The Virgins\nExplicit The Virgins"],["Putain de toi: Un hommage \u00e0 Brassens Les T\u00eates Raides"],["Singulier (disc 2) Jean-Jacques Goldman"],["Back to the Movies: Hits From the Flix (disc 2) Dusty Springfield"],["Kill Bill: Vol. 1 Various Artists : Kill Bill"],["Four Women: The Complete Nina Simone On Philips Nina Simone"],["The Age Of The Understatement The Last Shadow Puppets"],["No Need To Argue The Cranberries"],["The Doors of Heaven The Doors"],["Black Holes and Revelations Muse"],["Collected Massive Attack"],["The Police The Police"],["Alternative Times, Volume 74 Various Artists : Alternative Times"],["Mirror Mirror Ghinzu"],["Alternative Times, Volume 70 Various Artists : Alternative Times"],["Monday's Ghost International Version Sophie Hunger"],["Monday's Ghost Sophie Hunger"],["The Ultimate Collection (disc 4) Michael Jackson"],["Rise and Fall, Rage and Grace The Offspring"],["The Boy Does Nothing\nSingle DMD Alesha Dixon"],["The Best No. 1 Singles in the World... Ever! (disc 2) ABBA"],["Quiet Nights\nInt'l Digipak Version Diana Krall"],["The Platinum Collection (disc 2: Greatest Hits II) Queen"],["Le Bal Des Gens Bien Salvatore Adamo"],["Les Copains D'Abord Georges Brassens"],["Human\nInt'l 2 trk The Killers"],["Comme Un Manouche Sans Guitare Thomas Dutronc"],["50 Years of the Greatest Hit Singles (disc 2) Culture Club"],["Best Of Funk Various Artists : Funk"],["Motown Love Various Artists : Motown Love"],["2001 Dr. Dre"],["Le Village Des Enfoir\u00e9s Les Enfoires"],["Anthologie Florent Pagny"],["Echoes: The Best of Pink Floyd (disc 2) Pink Floyd"],["Hall Of Mirrors Grace"],["All The Plans Starsailor"],["En Attendant Les Caravanes... LA RUE KETANOU"],["RIOT! Paramore"],["Izia Izia"],["Mon Paradis\ncristal Christophe Mae"],["Lest We Forget (The Best Of) Marilyn Manson"],["By the Way Red Hot Chili Peppers"],["A Night at the Opera Queen"],["Now That's What I Call Music! 61 (disc 1) Audio Bullys"],["Libellule Marina"],["Les 50 Plus Belles Chansons Eddy Mitchell"],["Def Jam 25: Volume 1 - DJ Bring That Back (2008-1997)\nExplicit Version Various Artists : Def Jam"],["Stadium Arcadium (disc 1: Jupiter) Red Hot Chili Peppers"],["L'Essentiel - 1977-2007 (disc 1) Francis Cabrel"],["Free-Patri-Ation Patrice"],["Now That's What I Call Music! Janet Jackson"],["Talents Vol 1 Georges Brassens"],["Chanson Pour L'Auvergnat Georges Brassens"],["Talents Du Si\u00e8cle Volume 1 Georges Brassens"],["Black Holes And Revelations\nUS Only Version Muse"],["Black Holes And Revelations\nStandard DMD w\/o PDF Muse"],["Black Holes And Revelations\nStandard DMD & PDF Muse"],["Music of the Millennium (disc 1) Prince"],["Noir Desir En Public Noir D"],["Hot Rocks 1964-1971 The Rolling Stones"],["Play Moby"],["Talents Du Si\u00e8cle Volume 3 Serge Gainsbourg"],["Talents Vol 3 Serge Gainsbourg"],["Master S\u00e9rie Vol.3 Serge Gainsbourg"],["Now Spring 2008 Various Artists : Now Spring"],["The Singles 86>98 (disc 1) Depeche Mode"],["The Joshua Tree U2"],["The Hits 2 Prince"],["Artificial Animals Riding On Neverland Aaron"],["Disturbia\nint'l ECD Maxi Rihanna"],["Meet Me Halfway Black Eyed Peas"],["Pablo Honey Radiohead"],["Fearless: Zoom Jasari+ Mixed Run Various Artists : Fearless Zoom Jasari Mixed Run"],["...Hits Phil Collins"],["Dardanus - Suite d'orchestre Jean-Philippe Rameau"],["Disturbia\nInt'l 2trk Rihanna"],["The Best of Bob Dylan, Volume 1 Bob Dylan"],["Pulp Fiction Various Artists : Pulp Fiction"],["Comme \u00e0 la maison Christophe Mae"],["Disturbia Rihanna"],["Ballades Johnny Hallyday"],["Ouvert A Double Tour LA RUE KETANOU"],["Parachutes Coldplay"],["Spirit Of The 80ies Various Artists : Spirit Of The Ies"],["Freedom\nInt'l Version 2 Akon"],["Fight Club The Dust Brothers"],["Ministry of Sound Chillout Classics CD 1 Various Artists : Ministry Of Sound Chillout Classics"],["A Contresens LA RUE KETANOU"],["Lenny Lenny Kravitz"],["Tous les Sens Ariane Moffatt"],["The Best of The Doors (disc 1) The Doors"],["The Singles The Clash"],["Capital Gold Legends, Volume 1 (disc 2) Various Artists : Capital Gold Legends"],["0.9 Booba"],["World Go Round Busta Rhymes"],["Tracy Chapman Tracy Chapman"],["Des Visages Des Figures Noir D"],["Intl Singles Box Set\nInternational Version Eminem"],["Promo Only Alternative Club June Various Artists : Promo Only Alternative Club"],["Dutch Dance Charts Top 30 Week 15 Greg"],["Good Bye Lenin! Yann Tiersen"],["La Femme Chocolat olivia ruiz"],["Triple Best Of Eddy Mitchell"],["Number Ones ABBA"],["Crack A Bottle\nExplicit Version 50 Cent"],["War U2"],["Music Hole Camille"],["Greatest Hits The Doors"],["How to Save a Life The Fray"],["Greatest Hits bruce springsteen"],["Best of 1980-1990 Various Artists"],["Good Evening New York City\nDigital Wide Paul McCartney"],["Ben Quoi? Didier Super"],["Vanessa Paradis Best of Vanessa Paradis"],["Je Veux \u00catre Une Star Didier Super"],["BRITISH rendez-vous Music Is Not Fun"],["Let It Beep Royal Bangs"],["My Shoes Single Version Music Is Not Fun"],["Hobo (Special Edition) Charlie Winston"],["Island Reggae Triple Best Of Various Artists : Island Reggae Triple"],["H\u00f4tel Costes A Decade by St\u00e9phane Pompougnac I:Cube"],["Vous Remercier Jena Lee"],["Cool - Pop Various Artists : Cool"],["Die Mitte Transbeauce"],["Anthologie Serge Gainsbourg"],["Best Summer Club Hits Various Artists : Best Summer Club Hits"],["Russian Roulette\nGerman 2 trk Rihanna"],["Russian Roulette Rihanna"],["Vitamine Party Various Artists : Vitamine Party"],["Vaut Mieux En Rire Que S'En Foutre Didier Super"],["Fiesta Fever Various Artists : Fiesta Fever"],["Bad Romance Lady GaGa"],["Sortir G\u00e9rald de Palmas"],["JIWA 24 Hours Party Mix By Repie FP Paul Cooper"],["In the Mood for Life WAX TAILOR"],["Les N\u00b01 Johnny Hallyday"],["Le Clan Des Miros Renan Luce"],["69 Ann\u00e9e Erotique Serge Gainsbourg"],["Up To Now UK Digital Version Snow Patrol"],["Black Holes And Revelations\nUpdated 09 version Muse"],["Divinidylle\nEdition Collector Digitale Vanessa Paradis"],["Curtain Call\nDeluxe Explicit Eminem"],["Break Up Pete Yorn"],["Reise, Reise Rammstein"],["The Story of the Clash, Volume 1 (disc 1) The Clash"],["Divinidylle Vanessa Paradis"],["Coffret 3CD Vanessa Paradis"],["The Wall (disc 1) Pink Floyd"],["Lest We Forget (The Best Of) Deluxe PAL\nInternational Version (Explicit) Marilyn Manson"],["If On A Winter's Night Sting"],["Rue du temps Les Ogres de Barback"],["Cool - R&B Various Artists : Cool"],["Coffret 2CD Vanessa Paradis"],["Transformers: Revenge Of The Fallen The Album Various Artists : Transformers Revenge Of The Fallen"],["Tales Of The Forgotten Melodies WAX TAILOR"],["Starlight\nUpdated 09 Muse"],["Reise, Reise Megaherz"],["Je dis aime M"],["The Best Anthems ... Ever! (disc 1) Various Artists : The Best Anthems Ever"],["The Magic of Enya Enya"],["Coffret 2 CD Vanessa Paradis"],["R\u00eaves gregory lemarchal"],["MTV Buzz Bin Various Artists : Mtv Buzz Bin"],["Elephunk Black Eyed Peas"],["Jiwa 24 Hours Party Mix By Repie FP Djuma Soundsystem"],["Clash on Broadway (disc 3) The Clash"],["The Best of the Best Air Guitar Albums in the World... Ever! (disc 3) Various Artists : The Air Guitar Albums In World Ever"],["The 12\" Collection Queen"],["Bohemian Rhapsody \/ These are the Days of Our Lives Queen"],["Rock Times, Volume 11: 1975-1976 Queen"],["2 CD Volume 2 Renaud"],["Greatest Hits 98 Radiohead"],["Dancefloor Fg Et\u00e9 \/ Summer 2009 Various Artists : Dancefloor Fg Ete Summer"],["Rated R Rihanna"],["Jiwa 24 Hours Party Mix By Repie FP Caetano Veloso"],["Greatest Hits The Cure"],["Towering Above the Rest (disc 10) Radiohead"],["JIWA 24 Hours Party Mix By Kev Obrien Kobbe & Balthazar"],["The Best Bands... Ever! 2004 (disc 2) Iggy Pop"],["The Flying Club Cup Beirut"],["Elephant The White Stripes"],["The Definitive Collection Michael Jackson"],["Erotic Lounge: Deluxe Edition (disc 1) Various Artists : Erotic Lounge"],["mega disco Various Artists : Mega Disco"],["Anyone Can Play Guitar Radiohead"],["S.F.W. Radiohead"],["N\u00b01 Michel Sardou"],["Les petits chanteurs de la ma\u00eetrise de la cath\u00e9drale de strasbourg \/ strasbourg cathedral's children choirs Various Artists : Les Petits Chanteurs De La Maitrise Cathedrale Strasbourg Cathedral Children Choirs"],["The Blueprint 3 Jay-Z"],["Come Away With Me Norah Jones"],["Platinum Collection David Bowie"],["Crise De Conscience Kool Shen"],["Q: The Best Tracks From the Best Albums of 2000 Bloodhound Gang"],["Cool - One Hit Wonders Various Artists : Cool"],["West Ryder Pauper Lunatic Asylum Kasabian"],["Anthologie Georges Brassens"],["Et S'il N'en Reste Qu'un Eddy Mitchell"],["Coffret 2CD Eric L\u00e9vi"],["Cafeine Christophe Willem"],["Best Of Eddy Mitchell"],["Best Of\nVersion Cristal Eddy Mitchell"],["Happy Songs (disc 1) Various Artists : Happy Songs"],["Encyclopedia Of Rock Vol. 1 Various Artists : Encyclopedia Of Rock"],["Echoes: The Best of Pink Floyd (disc 1) Pink Floyd"],["Blur: The Best Of Blur"],["We Sing. We Dance. We Steal Things.\niTunes Jason Mraz"],["Les titres essentiels reggae Various Artists : Les Titres Essentiels Reggae"],["Fetenhits: Rock Classics (disc 1) Guns N' Roses"],["Midi 20 Grand Corps Malade"],["Manual For Successful Rioting Newcleus"],["Gladiator - Music From The Motion Picture\nSpecial Anniversary Edition Hans Zimmer"],["Hits 60 (disc 2) Various Artists : Hits"],["MTV Unplugged In New York Nirvana"],["The Essential Clash (disc 2) The Clash"],["La Maison de Mon R\u00eave CocoRosie"],["LES PLUS GRANDS SLOWS\ndigital album double LES PLUS GRANDS SLOWS"],["Encyclopedia Of Pop Vol. 3 Various Artists : Encyclopedia Of Pop"],["Dark Side of the Moon Pink Floyd"],["Hebron Gate Groundation"],["Greatest Hits Gloria Estefan"],["Greatest Hits 2004 Linkin Park"],["Pirates of the Caribbean: At World's End Hans Zimmer"],["L'Autre Bout Du Monde (Edition Sp\u00e9ciale) Emily Loizeau"],["Le Tour de -M- (disc 1) M"],["D\u00e9but Junior Caldera"],["Relator [from the album \"Break Up\"] Pete Yorn"],["Erotic Lounge 4: Bare Jewels (disc 1: Soft and Lazy) Various Artists : Erotic Lounge Bare Jewels"],["Best of Bowie David Bowie"],["Donnie Darko Michael Andrews"],["Donnie Darko (disc 2: The Score) Michael Andrews"],["De Afrekening, Volume 33 T.Raumschmiere"],["Let The Truth Be Told [Deluxe] Laura Izibor"],["Ahora '02 (disc 2) Kylie Minogue"],["The Very Best Of Era Era"],["Le Tour De M M"],["Le best of Les Wriggles"],["Jiwa 24 Hours Party Mix By Repie FP Nina Simone"],["La Roux La Roux"],["The Cream Of Clapton Eric Clapton"],["Best Of 2003 Michel Polnareff"],["JIWA 24 Hours Party Mix by Repie FP Various Artists : Jiwa Hours Party By Repie Fp"],["Reggae Roots 1972-1995 Vol.5 Various Artists : Reggae Roots"],["Creedence Clearwater Revival - Best Of Creedence Clearwater Revival"],["Tea for the Tillerman deluxe set Cat Stevens"],["Best Of 1CD-2 Eddy Mitchell"],["Tea For The Tillerman Cat Stevens"],["Et\u00e9 En F\u00eate Various Artists : Ete En Fete"],["Decode\nInternational Paramore"],["A Kind of Magic Queen"],["Eddy Mitchell Eddy Mitchell"],["All Time Greatest Hits Lynyrd Skynyrd"],["JIWA 24 Hours Party Mix By Chefrocker Mauro Picotto"],["Carmen Maria Vega Carmen Maria Vega"],["The World's Greatest (disc 1) Prince"],["HITS 2008"],["Nouveaut\u00e9s POP"],["RADIO LOUNGE"],["RADIO ROCK"],["RADIO CLUB"],["Nouveaut\u00e9s Rock"],["Nouvelle Sc\u00e8ne"],["RADIO GOLD ROCK"],["RADIO POP"],["Musiques de Pubs"],["Chanson Fran\u00e7aise"],["bo\/track"],["soul\/track"],["Jazz"],["Ann\u00e9es 80"],["funk\/track"],["24 Hours party mix"],["Greatest Hits of All Time"],["Blues"],["urban\/track"],["Super g\u00e9niale classique"],["Joshua Radin Someone Else's Life"],["RADIO GOLD POP"],["Nouveaut\u00e9s HipHopRnB"],["Slow"],["RADIO METAL\/HARDCORE"],["Gold Chanson Fran\u00e7aise"],["Reggae"],["Happy"],["disco\/track"],["Radio baroque"],["FSOL"],["Cowboys fringants tr\u00e8s fringant"],["90's music"],["World"],["RADIO SALSA"],["Random"],["Arvo Part"],["reprises"],["Movies Soundtracks"],["La chanson francaise se d\u00e9vergonde."],["Fabienne Thibeault"],["New Reggae Dancehall"],["anthologie pop rock"],["Musiques de films - Ennio Morric"],["Dance Floor"],["soir\u00e9e"],["RADIO RAP\/RNB FRANCAIS"],["ANNEES 80"],["play 3"],["Wake up!!"],["Music For Soul"],["ma playlist"],["playlist1"],["Summer nights"],["Renaud sympa"],["Bach Sonates Flute"],["RADIO POP ROCK"],["Party 80"],["R&B Love"],["timmy fantastic"],["G\u00e9niale classique"],["RADIO Enfants"],["Nostalgia"],["Brahms"],["test"],["guildevi"],["D\u00e9couverte"],["REVEILLON CLUB 2009"],["2009-10 Fall-Winter, Spring-Summer Fashion Show Catwalk Music"],["Disney"],["Fashion Week Soundtracks: PE2010 & AH2009"],["tropical\/track"],["B.O"],["Chansons"],["Reprises\/Covers"],["Teenage rock"],["MORENICA - Chansons S\u00e9farades "],["Chill"],["90's rap us"],["80's pop (new wave 1979-1988 timeline)"],["Chanson FR"],["Keep Zen Spirit"],["Rock Soleil "],["tit' pop rock"],["Cool Quiet Ambient Zen Emotion"],["Chanson fran\u00e7aise... Ou pas"],["Nina"],["La playlist de six-sous"],["grey's anatomy s 4"],["G\/Slow Blues"],["divers"],["Berceuses"],["Travail"],["Fran\u00e7ais"],["de tout"],["Women Voices"],["chansons pr\u00e9f\u00e9r\u00e9es"],["John Bullard"],["Reveillon 2009"],["coolest lounge stuff"],["RA\u00cf"],["Les titres en chansons"],["Bruit de la pluie"],["DanceFloor 2\u00f610."],["skydive"],["The Jiwa weekly favorite picks"],["BRASIL LOUNGE"],["electro bb"],["favoris"],["L\u00e9o f\u00e9rr\u00e9"],["Op\u00e9ra"],["Christmas"],["ALL TIME FAVORITE BY LEVY CABRERA"],["Favoriten"],["Lounge - Jazz"],["enrico macia n\u00b01"],["dance afro"],["REVEILLON FRANCAIS 2009"],["fmusic2"],["Black 80"],["jasper's love songs collection"],["Latina"],["Chansons de marin"],["Cello"],["OLi!"],["PopJazz\/Jazz&Bossa"],["Divers"],["London baroque"],["Thibtoons"],["Flower Power"],["THE ANIMALS"],["Salsa around the world"],["Amazing grace"],["Bistro Urbain Cool"],["BLOOSE"],["hallyday"],[" Bach Cembalokonzert"],["GuiM Jiwa Playlist"],["Musique "],["The 500 All Time best albums"],["Getz \/ Gilberto"],["Guitar hero 2"],["berdon"],["House"],["pinoy me..lol"],["purple music"],["lune"],["My new playlist"],["BIO taffe"],["Radio Nova"],["French chansons"],["D\u00e9prime"],["top"],["STEVE VAI"],["girls"],["Playlist1"],["Detente soir Lounge"],["nitty gritty"],["US Style"],["matthew wilder"],["All"],["priscillia"],["twist"],["Best of NIN"],["Bach Clavecin Guitare"],["Play it again: Alternative: Post Grunge"],["Cool music"],["Pop rock and more"],["the cranberries"],["REVEILLON HIP HOP\/DANCEHALL 2009"],["medianeuve"],["tfough"],["melimelo de mely"],["coup de coeur "],["Heavy"],["Dieupart Frans Bruggen"],["Wake Up !!! (and take it easy I'm at your side)"],["Ambiant \/ Trip Hop \/ Electro"],["Electro House"],["Dance music"],["French Oldies"],["GARBAGE"],["mix perso"],["Girls Powers"],["Ambiance"],["Morceaux Choisis"],["cyril"],["Bastien"],["mouton"],["The Bourne Supremacy"],["mel"],["Appart Raph & Lucy"],["Absolute Fav's"],["santaweed"],["concert 29\/11"],["gerry raffarty"],["Space invaders"],["Sweet sixties 3"],["Top songs"],["Metal nouveau"],["Soir\u00e9e verre de vin"],["smoothy"],["ajja432"],["BesT.EveR"],["J'Suis conne"],["PlayList 1"],["Rap Fran\u00e7ais"],["Id\u00e9e de Valses de mariage"],["RYTHM'N'BLUES"],["Nouvel an Chinois"],["Ma playlist"],["all"],["nat king cole"],["Rnb"],["didier"],["jewel"],["pinoy banda"],["Reprises"],["Rustig"],["GTplaylist"],["La fin est arriv\u00e9e..."],["boulot"],["Clo"],["boogybites"],["Beatles"],["zik"],["oscar peterson trio"],["Birdy Nam Nam \/ DJ Pone"],["Maureen Dance"],["Party"],["LA NOUVELLE CHANSON FRANCAISE"],["kaleidoscope"],["My Favorits"],["List for other stuff"],["Playlist"],["CALORADIO"],["Helen's Playlist"],["eminem"],["MUSIC PT AVEN"],["dean"],["movies"],["ce soir"],["list1"],["Tranquillous"],["FIFTIES AND SIXTIES"],["Exclusive - Chris Brown"],["la tordue"],["dafmoi's playlist"],["Reggae sous toutes ses formes"],["Danny Diablo"],["Fab_list"],["soir\u00e9"],["liste1"],["mhelene"],["playlist"],["Top Playlist !"],["playlist 1"],["Jean ferrat"],["rondine"],["assedu"],["Krall"],["f\u00eate"],["Le Monde des Soundtracks"],["vari\u00e9t\u00e9 fran\u00e7aise contemporaine"],["invitation"],["movies soundtracks"],["Douce France"],["Be Your Own Pet"],["BrunoSong"],["list 2"],["Goldies"],["Rock"],["Mes ziik"],["a vos micros les ptits"],["mix"],["Trip hop"],["rock"],["To I-Pod"],["Love songs"],["techno"],["Gounod"],["furia09"],["fred3"],["Break"],["transbeauce"],["FOLK & ROCK"],["rammstein"],["Des trucs qui bougent"],["13.11.09"],["Evasion"],["Playlist 001"],["salon"],["music top anne so"],["HipHop"],["Rap"],["Dj Shadow, Massive Attack & Co"],["Instu"],["ind\u00e9"],["Joyeux No\u00ebl"],["best"],["Rock tranquille"],["tit' nassels"],["Coup d'coeur integral"],["ce que je kiffe"],["Exelllllllll"],["1 AN DE COUPS DE COEUR"],["WoW"],["songs_ulath"],["pubbb"],["Sovann"],["PasDeNom"],["playlist jihuty"],["Sarah"],["Every"],["Dune - Brian Tyler"],["bon rap k'1ry"],["Dancefloor"],["Lu' playlist"],["Bjork"],["Red House"],["tout"],["P'TIT DICO DES NOMS PROPRES by Dan' & Phil'"],["JN"],["giada"],["ambiance 2"],["Playlist Tony"],["Pierre Ch\u00eane"],["new"],["Sc\u00e8ne fran\u00e7aise ... ou pas"],["Etta James"],["l'air de rien"],["home"],["Best of OST"],["Musik"],["electro & hits"],["ma playlist 1"],["black"],["aurore"],["Grey's anatomy"],["Irish"],["KiKoS"],["aurelie"],["MiGoii On The TV"],["aaaaaaaaaaaa"],["ALL."],["md radio"],["gainsbarre"],["\u00e7a passe"],["For us"],["RadioHead"],["Top 100"],["soir\u00e9e bar 11\/2009"],["Best songs of 80s"],["AAARRRGGGHHH !!!"],["fgh"],["1 hiver, 25 printemps."],["love songs"],["specialistepc"],["zik2val."],["Austin_Powers"],["Reggae Roots Vibration"],["NEW DIVERS"],["magasin"],["Hey"],["detoutaudebut"],["boubou"],["pink shadows"],["SENTIMENTAL BALLADS"],["Energy Never Die"],["The Best of Bacquy Selection"],["SOIREE DU 5 DECEMBRE"],["Frankenstein"],["Moi"],["MON ESSENTIEL DU ROCK"],["my tune"],["pour tous"],["memokaraoke"],["Playlist 1"],["Playlist Stan' =)"],["Jiw'me baby"],["Robert Walton's Blues"],["AllUs"],["Soir\u00e9e"],["Trankiloo"],["BOF"],["Lounge"],["Musique de VM Akoni =D"],["Best of"],["moi"],["In the Mood"],["RicouPlayListPop"],["EKLEKTIK"],["Night Club"],["That sound is ..."],["di-ff\u00e9rents...psycho,patho,n\u00e9vro...."],["Woot"],["Prem"],["hey hey"],["Now"],["M\u00e9nage !!"],["chillout"],["Regarde, j'\u00e9coute de la merda"],["cassienne"],["Chansons de noel"],["ramazzotti"],["Test2"],["Revolution"],["DECHIRURE"],["nighttime"],["The WALL (Pink Floyd)"],["hits"],["discoth\u00e8que Funk"],["S"],["mata"],["Favoris"],["reggae"],["melange"],["MyRock74"],["House\/Electro\/Rap-Rnb\/Dancefloor"],["vrac"],["R\u00e9mi"],["ELISA"],["apero gerhard"],["3-6"],["tous genres"],["decouverte"],["Un peu de tout"],["Medinar"],["Philgido"],["hard rap"],["GreySky"],["Doux"],["lady gaga"],["chanson francaise"],["Piano, soit une voix au bout de mes doigts"],["Morning Special"],["M\u0454s \u00a2OuPs D\u0454 <3"],["Ce que J'idol\u00e2tre"],["SOFT BRANCHE"],["rock blues"],["Top Dance"],["Medley X"],["my better bat l'beurre"],["kop"],["JUNGLE TRIP HOP DUB ELECTRO"],["ma playlists \u00e0 moi"],["Best of cin\u00e9"],["jazz"],["french touch"],["Hits vari\u00e9s r\u00e9cents"],["RETIF"],["caouic1"],["Nathalie"],["Ascpb"],["S\u00e9verin"],["smokes"],["A\u00e9rien"],["PL1"],["Best CLUB 2009 (Bass explosion)"],["brel"],["1"],["So"],["christophe beck"],["top club"],["Game"],["CEDRIC"],["apero"],["culte"],["vacance"],["beautiful"],["Bouzaa"],["Emir Kusturica"],["Musiques de Films"],["Play 1"],["Best of Fab'S Rock"],["preference"],["DANCEFLOOR_1"],["CLASSIQUE VIOLON"],["D'la chanson fran\u00e7aise!"],["Dido and Aeneas"],["monique"],["Aerial"],["Spleen #2"],["\"Coulez, sensations\""],["Divers 1"],["dependaison"],["Xmas"],["Andrea Parodi"],["relaxation n \u00b02"],["rocklipop"],["My playlist"],["PLAYLIST REPRISE"],["reggae tunes"],["LA TOTALE"],[" soul"],["I love music!!!"],["blind test jerome"],["TOUJOURS !...."],["Alan Parsons Project"],["2007 07"],["kttt"],["kiki"],["zazaplay"],["Piano styl\u00e9 \/ D\u00e9tente"],["ap\u00e9ro"],["musique"],["Agn\u00e8s"],["Cool New age Deep blue"],["FP"],["mange ta vie!!"],["Guignol's music"],["francophone"],["Rap \/ Hip Hop FR"],["Musique de rue"],["Rock en espa\u00f1ol"],["humeur"],["hernault"],["Capoucine"],["DD top"],["Lulu's playlist"],["Dinner doreen"],["Melodies d'un Dimanche Apr\u00e8s-midi sous la Pluie"],["Paynlist"],["HOP-HOP"],["La playlist du Bien"],["m\u00e9lange"],["jazzy"],["Soir\u00e9e dofus"],["Roland's Music"],["vari\u00e9t\u00e9 fran\u00e7aise"],["Beyonc\u00e9"],["Tout absolument tout"],["a la cool"],["c\u00e9line"],["matteo"],["Helaine"],["MissMoi"],["Lillypop"],["Tom92"],["flocello"],["jiwa"],["karwaille"],["Lady Jay"],["ubik"],["tekila"],["GuillaumeL"],["repie fp"],["Kal\u00e9os"],["sassy"],["sirjohn"],["kitesurfingdude"],["Hans Gruber"],["Laureeen"],["grouk"],["tassin62"],["littlewing"],["fabrice"],["six sous"],["eestebam1"],["SJA4JIWA"],["mjaa"],["damedesu"],["luisray"],["Antoine76"],["titwix"],["LEXPRESS"],["milouboubou"],["triskelionjas"],["pelos"],["locktime"],["maxonerock"],["dolphinman83"],["bextors"],["weterie"],["Tony75013P"],["zebu"],["thalieparis"],["projet2501"],["Helloween"],["SqTH"],["chmary"],["katia54"],["Patte Blanche"],["pom2ter"],["dany45"],["GeoD"],["bilbog"],["gtejedor"],["AlloMusic"],["radio sevojno"],["fkdb"],["Galettislandaise"],["seringat59"],["ammakoala"],["tib59"],["beat twin"],["Psylo"],["guim"],["mrt45"],["toto ce heros"],["LMDMP"],["wladyslaw"],["ulric33"],["Mansour123"],["makno"],["ynnaf"],["nocken"],["guatemalt"],["boubou64"],["codger"],["clubA"],["KoalaKanaille"],["Arucamba"],["quintetsens"],["valmante"],["Bensmens"],["gautier"],["daydreamer"],["sultanhalarawi"],["Albon07"],["qu ilest marrant"],["dropocean"],["JLMAN"],["pinkcalysto"],["DESALM "],["PochyPoch"],["Promoiti07s"],["NicoTux"],["Xav44"],["Nietzsche64"],["Hiro53"],["wilh35"],["magic081"],["keuagringo"],["Badintello"],["mikou01"],["melanaille"],["Niny54"],["koad9"],["sb35"],["francois33"],["Deezer vers Jiwa"],["bel oeil"],["mrs mays 72118"],["Mouton12"],["grytalors"],["dena13"],["Barlive After"],["tom74"],["lolo80780"],["saesh"],["jerrrr"],["BBRT14"],["lotonove"],["Sinmora"],["nyco_san"],["NPO2"],["seelen"],["jazzmusique"],["gizmo63"],["Ender Gonul"],["naomiu"],["missvanille"],["NPO"],["ATAMO"],["GOBBO"],["publascuderia"],["iouiou"],["Penpen"],["SavoirDanser"],["chirimoya"],["faerethuir"],["molluscum"],["didier77330"],["fredysa"],["vinco1978"],["jewel80"],["Galinou16"],["BakaChev"],["myry"],["gagaman"],["lolo7300"],["nime"],["cliclou"],["Lillyne"],["Gontier"],["tedLaTomate"],["Sandra CG32"],["jbagulto"],["ioio"],["davidmaxime"],["caline62"],["chatouneinlove"],["snakefast"],["erix"],["stef2k8"],["CottonPellet"],["voldenuit"],["papyrourou"],["Calinologue"],["mickl29000"],["Msansm1"],["ottawa"],["shannok"],["Coclia"],["paddyscorner"],["Umia"],["n0rad"],["livli"],["Seeking Bot"],["minederien"],["Les Voyageurs"],["goutagg"],["quentinfernet"],["keyrio"],["pringlesz"],["mehdi94"],["Meloku"],["vero43"],["alya"],["DourFestival2009"],["spi"],["euterpe6"],["kriss2valnor"],["DidoEric"],["katrouchka"],["baboo35"],["tiennou.b"],["bobby1406"],["sarph"],["bavbav"],["Aaliyah185"],["gzitta"],["palipo"],["Amochaix"],["hankv2"],["Miriel"],["DivineComedy"],["currt"],["lug79"],["raphcity"],["garp"],["anahop"],["redgasoil"],["feeldizzy"],["coaleboa"],["Adikill"],["Lavi"],["Laitram"],["Hardouin"],["lkzawi"],["vtranvaux"],["ernalda"],["Daads83"],["toxicdeath"],["Gregco"],["zikabrac"],["thefreyr"],["jamessss"],["denspirit"],["Thisisapseudo"],["Chakii"],["zaza56"],["maissa"],["332960073452"],["cocopipo"],["Atlantis06"],["Lauwi"],["nagperso"],["pixelgirl"],["Hugronez"],["jcp33"],["locean29"],["stech2b"],["tolismolis"],["Dvb"],["tresor77"],["lililafripouille"],["fabio85"],["funtooth"],["rcupiol"],["cid61"],["ekipilou"],["Drawer"],["Reboul69"],["Jarann"],["gui94370"],["steph22s"],["lolo1971"],["luludemars"],["Florian671"],["Irish Times"],["caloune"],["scarlett"],["kanbee"],["tsmoi"],["makaze"],["sulnok"],["Benjack22"],["soubok"],["michel"],["Sophocle"],["Hysteria"],["didoo12"],["bouddette"],["frozenparty"],["bob15"],["asunn"],["tequilla"],["GaryMooreFan"],["brice23"],["Groseilleb"],["tontonbatou"],["Perfection"],["dulno"],["sophermarcha"],["flancharmant"],["ALERTE"],["entopan"],["birdlepistolero"],["ponstyl"],["kalium"],["slay547"],["Ybrax"],["commodore"],["titegrace"],["rilote"],["vincality"],["Jerome69"],["jankan"],["Julie.A"],["evangeneer"],["Shinma"],["lol0ve13"],["Earl_le_gris"],["anton.nancy"],["annesophie76000"],["asmographe"],["le1erdragon"],["noisekiller"],["Sarachou1"],["greg78"],["nicopleu"],["foupoudav14"],["TomyFiction"],["justpepper"],["bumpshoveit"],["Niac039"],["ANTOHCDTony"],["Enaldoriel"],["pititeaude"],["exel"],["heriac"],["moukyone"],["Ulath"],["renesantos"],["dinnyosz"],["DasoFran"],["mimisio"],["jihuty"],["Broussaii"],["ju2-6tron"],["Yuanji"],["Skyhook75"],["bourriquet"],["Taz 64"],["Joyce Lombaert"],["stefdu29"],["MoRtY82"],["kaskete"],["happybunny"],["la Boule"],["oxidor"],["francklyon01"],["Gushigan"],["lamaryllis"],["scarlettianh"],["mekk"],["JN2"],["petibara"],["Nanouzeno"],["tonyjee"],["Arwen46"],["kiki_2009"],["bayaflici"],["36FLIP"],["atrius"],["Gil Galad"],["sangius"],["air de rien"],["nat672"],["mdrmdr"],["Ruki sensei"],["Lanfeu"],["HeyHannah"],["keiko2009"],["aware"],["lasperge"],["kristo68"],["migoii"],["Kees"],["vcobra"],["PATARMENEZ"],["dju_hyppe"],["celine imagine"],["atlantique 44"],["bibi056"],["cedric3428"],["Onde de Choc"],["sweetmother"],["anak1"],["BBorderline"],["vayoh"],["belettetete"],["maximedestoop"],["aslan72"],["noireva"],["Thib59dk"],["dri61"],["Misscarly"],["nicoco1"],["spouic"],["VM Akoni"],["sebinnis"],["aiolos"],["Lartdeloptique"],["glubuck"],["valbouille"],["HOGUN2"],["lesparre"],["Lecodub"],["bacquy"],["aurelily"],["ouftidju17"],["darkjc01"],["tshin-tshin"],["CosmicDebris"],["tr6"],["dancewithewords"],["Slay7"],["nathslooc"],["Mattatat"],["immobylis"],["heihei"],["sagittaire3"],["Neuphreyou"],["jeanmi78"],["Jyde"],["Little Bud"],["YunaPikachu"],["supermann"],["barjojo01"],["Peusdo"],["Don54"],["Penut's"],["riverainpsy"],["thibaud77"],["notenshi"],["balthazar260"],["Gilith"],["jamesblonde"],["pubsimj"],["viva64"],["ARWEN LIZ"],["cricounit"],["Ricou13"],["CaroleLegrand"],["Rhumrhum"],["emy39"],["robbie92000"],["freeze5729"],["XeK"],["kohiwo"],["Kasfete"],["PyjamaDragon"],["bigtchit"],["jcsauzon"],["laurefx"],["earl06"],["Vanzan"],["strneb"],["BoysDuS\u00e9v\u00e8re"],["mael-sensei"],["pulposa"],["joris6908"],["Topazine"],["Msuze"],["Satrium"],["magiccerbere"],["freeman_new"],["roh01"],["golgot33"],["ricotimor"],["Jaden54"],["Singepito"],["sviato"],["Julezz"],["matta"],["slashy15"],["eviltribe"],["gildane"],["bart74"],["melili"],["Youmimix"],["myms"],["fortiche"],["Paul H"],["grognou"],["patatinouche"],["lorenzo31"],["pitiless"],["LilySly"],["monsieurchou"],["chococolapin"],["Ju+"],["PHILGIDO"],["aogara"],["fil011"],["Diego10"],["aldo95"],["Mijolo"],["Shanya"],["flacone"],["simbazot2"],["simonthebeast"],["Marman"],["schlotschmed"],["geraldinevalluet"],["ADX911"],["naikicoul"],["yterza"],["Douda_185"],["tartenpiom"],["noraym"],["Clairette23"],["musicolle"],["Leyha"],["Steffff"],["Ludo75"],["bobiyi"],["keurt"],["jonath68"],["delirio"],["deneschau"],["klyde"],["Celadon"],["Blade"],["Magnifico"],["Severin"],["michou70"],["fabzz"],["caouic"],["Madamour"],["ninfar"],["Nelty86"],["vassililechat"],["domini56"],["chlag"],["SMOKES222"],["smerle49"],["MaDo"],["Moralph"],["supremdeus"],["fleury_cedric"],["Kouent"],["kiki67000"],["CATH3"],["mariecisse"],["bidibulle64"],["perledenuit"],["linoline"],["cessnaman"]];



/**
 *
 */
Ext.namespace( 'Ext.ux' );
/**
 *
 */
Ext.ux.ColorPicker = Ext.extend( Ext.BoxComponent, {
	/**
	 *
	 */
	initComponent: function() {
		this.applyDefaultsCP();
		Ext.ux.ColorPicker.superclass.initComponent.apply( this, arguments );
	},
	/**
	 *
	 */
	onRender: function() {
		Ext.ux.ColorPicker.superclass.onRender.apply( this, arguments );
		// check if container, self-container or renderTo exists
		this.body = this.body || ( this.container || ( this.renderTo || Ext.DomHelper.append( Ext.getBody(), {}, true ) ) );
		if( !this.el ) {
			this.el = this.body;
			if( this.cls ) { Ext.get( this.el ).addClass( this.cls ); }
		}
		// render this component
		this.renderComponent();
		this.addEvents({
			/**
			 * @event pickcolor
			 * Fires when a new color selected
			 * @param {Ext.util.ColorPicker} this
			 * @param {String} color
			 */
			pickcolor: true,
			/**
			 * @event changergb
			 * Fires when change rgb input
			 * @param {Ext.util.ColorPicker} this
			 * @param {Object} color ({ r: redvalue, g: greenvalue, b: bluevalue })
			 */
			changergb: true,
			/**
			 * @event changehsv
			 * Fires when change hsv input
			 * @param {Ext.util.ColorPicker} this
			 * @param {Object} color ({ h: huevalue, s: saturationvalue, v: brightnessvalue })
			 */
			changehsv: true,
			/**
			 * @event changehexa
			 * Fires when change hexa input
			 * @param {Ext.util.ColorPicker} this
			 * @param {String} color
			 */
			changehexa: true
		});
	},
	/**
	 *
	 */
	applyDefaultsCP: function() {
		Ext.apply( this, {
			'cls': 'x-cp-mainpanel',
			'resizable': this.resizable || false,
			'HSV': {
				h: 0,
				s: 0,
				v: 0
			},
			updateMode: null
		});
	},
	/**
	 *
	 */
	renderComponent: function() {
		// create RGB Slider
		Ext.DomHelper.append( this.body, {
			'id': this.cpGetId( 'rgb' ),
			'cls': 'x-cp-rgbpicker'
		});
		// Create HUE Slider
		Ext.DomHelper.append( this.body, {
			'id': this.cpGetId( 'hue' ),
			'cls': 'x-cp-huepicker'
		});
		// Initialize HUE Picker DD
		this.huePicker = Ext.DomHelper.append( this.body, { 'cls': 'x-cp-hueslider' });
		this.hueDD = new Ext.dd.DD( this.huePicker, 'huePicker' );
		this.hueDD.constrainTo( this.cpGetId( 'hue' ), {'top':-7,'right':0,'bottom':-7,'left':0} );
		this.hueDD.onDrag = this.moveHuePicker.createDelegate( this );
		// initialize onclick on the rgb picker
		Ext.get( this.cpGetId( 'hue' ) ).on( 'mousedown', this.clickHUEPicker.createDelegate( this ) );
		// initialize start position
		Ext.get( this.huePicker ).moveTo( Ext.get( this.cpGetId( 'hue' ) ).getLeft() - 7, Ext.get( this.cpGetId( 'hue' ) ).getTop() - 7 );
		// Initialize RGB Picker DD
		this.rgbPicker = Ext.DomHelper.append( this.body, { 'cls': 'x-cp-rgbslider' });
		this.rgbDD = new Ext.dd.DD( this.rgbPicker, 'rgbPicker' );
		this.rgbDD.constrainTo( this.cpGetId( 'rgb' ), -7 );
		this.rgbDD.onDrag = this.moveRGBPicker.createDelegate( this );
		// initialize onclick on the rgb picker
		Ext.get( this.cpGetId( 'rgb' ) ).on( 'mousedown', this.clickRGBPicker.createDelegate( this ) );
		// initialize start position
		Ext.get( this.rgbPicker ).moveTo( Ext.get( this.cpGetId( 'rgb' ) ).getLeft() - 7, Ext.get( this.cpGetId( 'rgb' ) ).getTop() - 7 );
		// Create color divs and Form elements
		this.formPanel = new Ext.form.FormPanel({
			'renderTo': Ext.DomHelper.append( this.body, {
							'id': this.cpGetId( 'fCont' ),
							'cls': 'x-cp-formcontainer'
						}, true ),
			'layout': 'column',
			'labelAlign': 'left',
			'labelWidth': 10,
			'items': [{
				'columnWidth': .5,
			'cls': 'x-cp-formcontainer-left',
				'items': [{
					
					'layout': 'form',
					'defaultType': 'numberfield',
					'defaults': {
						'width': 50,
						'value': 0,
						'minValue': 0,
						'maxValue': 255,
						'allowBlank': false,
						'labelSeparator': ''
					},
					'items': [{
						'fieldLabel': 'R',
						'id': this.cpGetId( 'iRed' )
					},{
						'fieldLabel': 'G',
						'id': this.cpGetId( 'iGreen' )
					},{
						'fieldLabel': 'B',
						'id': this.cpGetId( 'iBlue' )
					},{
						'fieldLabel': 'H',
						'maxValue': 360,
						'id': this.cpGetId( 'iHue' )
					},{
						'fieldLabel': 'S',
						'id': this.cpGetId( 'iSat' )
					},{
						'fieldLabel': 'V',
						'id': this.cpGetId( 'iVal' )
					}]
				}]
			},{
				'columnWidth': .5,
				'defaultType': 'textfield',
				'labelAlign': 'left',
				'layout': 'form',
				'defaults': {
					'width': 82,
					'value': '000000',
					'labelSeparator': '',
					'allowBlank': false
				},
				'id': this.cpGetId( 'cCont' ),
				'items': [{
					'fieldLabel': '#',
					'id': this.cpGetId( 'iHexa' ),
					'value': '000000'
				}]
			}]
		});
		Ext.getCmp( this.cpGetId( 'iRed' ) ).on( 'change', this.updateFromIRGB.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iGreen' ) ).on( 'change', this.updateFromIRGB.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iBlue' ) ).on( 'change', this.updateFromIRGB.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iHue' ) ).on( 'change', this.updateFromIHSV.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iSat' ) ).on( 'change', this.updateFromIHSV.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iVal' ) ).on( 'change', this.updateFromIHSV.createDelegate( this ) );
		Ext.getCmp( this.cpGetId( 'iHexa' ) ).on( 'change', this.updateFromIHexa.createDelegate( this ) );
		Ext.DomHelper.append( this.cpGetId( 'cCont' ), { 'cls': 'x-cp-colorbox', 'id': this.cpGetId( 'cColor' ) }, true ).update( '' );
		Ext.DomHelper.append( this.body, {'tag':'br','cls':'x-cp-clearfloat'});
	},
	/**
	 *
	 */
	cpGetId: function( postfix ) {
		return this.getId() + '__' + ( postfix || 'cp' );
	},
	/**
	 *
	 */
	updateRGBPosition: function( x, y ) {
		this.updateMode = 'click';
		x = x < 0 ? 0 : x;
		x = x > 181 ? 181 : x;
		y = y < 0 ? 0 : y;
		y = y > 181 ? 181 : y;
		this.HSV.s = this.getSaturation( x );
		this.HSV.v = this.getValue( y );
		Ext.get( this.rgbPicker ).moveTo( Ext.get( this.cpGetId( 'rgb' ) ).getLeft() + x - 7, Ext.get( this.cpGetId( 'rgb' ) ).getTop() + y - 7, ( this.animateMove || true ) );
		this.updateColor();
	},
	/**
	 *
	 */
	updateHUEPosition: function( y ) {
		this.updateMode = 'click';
		y = y < 1 ? 1 : y;
		y = y > 181 ? 181 : y;
		this.HSV.h = Math.round( 360 / 181 * ( 181 - y ) );
		Ext.get( this.huePicker ).moveTo( Ext.get( this.huePicker ).getLeft(), Ext.get( this.cpGetId( 'hue' ) ).getTop() + y - 7, ( this.animateMove || true ) );
		this.updateRGBPicker( this.HSV.h );
		this.updateColor();
	},
	/**
	 *
	 */
	clickRGBPicker: function( event, element ) {
		this.updateRGBPosition( event.xy[0] - Ext.get( this.cpGetId( 'rgb' ) ).getLeft() , event.xy[1] - Ext.get( this.cpGetId( 'rgb' ) ).getTop() );
	},
	/**
	 *
	 */
	clickHUEPicker: function( event, element ) {
		this.updateHUEPosition( event.xy[1] - Ext.get( this.cpGetId( 'hue' ) ).getTop() );
	},
	/**
	 *
	 */
	moveRGBPicker: function( event ) {
		this.rgbDD.constrainTo( this.cpGetId( 'rgb' ), -7 );
		this.updateRGBPosition( Ext.get( this.rgbPicker ).getLeft() - Ext.get( this.cpGetId( 'rgb' ) ).getLeft() + 7 , Ext.get( this.rgbPicker ).getTop() - Ext.get( this.cpGetId( 'rgb' ) ).getTop() + 7 );
	},
	/**
	 *
	 */
	moveHuePicker: function( event ) {
		this.hueDD.constrainTo( this.cpGetId( 'hue' ), {'top':-7,'right':0,'bottom':-7,'left':0} );
		this.updateHUEPosition( Ext.get( this.huePicker ).getTop() - Ext.get( this.cpGetId( 'hue' ) ).getTop() + 7 );
	},
	/**
	 *
	 */
	updateRGBPicker: function( newValue ) {
		this.updateMode = 'click';
		Ext.get( this.cpGetId( 'rgb' ) ).setStyle({ 'background-color': '#' + this.rgbToHex( this.hsvToRgb( newValue, 1, 1 ) ) });
		this.updateColor();
	},
	/**
	 *
	 */
	updateColor: function() {
		var rgb = this.hsvToRgb( this.HSV.h, this.HSV.s, this.HSV.v );
		var websafe = this.websafe( rgb );
		var invert = this.invert( rgb );
		var wsInvert = this.invert( websafe );
		if( this.updateMode !== 'hexa' ) {
			Ext.getCmp( this.cpGetId( 'iHexa' ) ).setValue( this.rgbToHex( rgb ) );
		}
		if( this.updateMode !== 'rgb' ) {
			Ext.getCmp( this.cpGetId( 'iRed' ) ).setValue( rgb[0] );
			Ext.getCmp( this.cpGetId( 'iGreen' ) ).setValue( rgb[1] );
			Ext.getCmp( this.cpGetId( 'iBlue' ) ).setValue( rgb[2] );
		}
		if( this.updateMode !== 'hsv' ) {
			Ext.getCmp( this.cpGetId( 'iHue' ) ).setValue( Math.round( this.HSV.h ) );
			Ext.getCmp( this.cpGetId( 'iSat' ) ).setValue( Math.round( this.HSV.s * 100 ) );
			Ext.getCmp( this.cpGetId( 'iVal' ) ).setValue( Math.round( this.HSV.v * 100 ) );
		}
		Ext.get( this.cpGetId( 'cColor' ) ).setStyle({
			'background': '#' + this.rgbToHex( rgb ),
			'color': '#' + this.rgbToHex( invert )
		});
		Ext.getDom( this.cpGetId( 'cColor' ) ).title = '#'+this.rgbToHex( rgb );


		Ext.get( this.huePicker ).moveTo( Ext.get( this.huePicker ).getLeft(), Ext.get( this.cpGetId( 'hue' ) ).getTop() + this.getHPos( Ext.getCmp( this.cpGetId( 'iHue' ) ).getValue() ) - 7, ( this.animateMove || true ) );
		Ext.get( this.rgbPicker ).moveTo( this.getSPos( Ext.getCmp( this.cpGetId( 'iSat' ) ).getValue() / 100 ) + 10, Ext.get( this.cpGetId( 'hue' ) ).getTop() + this.getVPos( Ext.getCmp( this.cpGetId( 'iVal' ) ).getValue() / 100 ) - 7, ( this.animateMove || true ) );
		Ext.get( this.cpGetId( 'rgb' ) ).setStyle({ 'background-color': '#' + this.rgbToHex( this.hsvToRgb( Ext.getCmp( this.cpGetId( 'iHue' ) ).getValue(), 1, 1 ) ) });
	
		this.fireEvent( 'pickcolor', this, this.RGB );
	},
	/**
	 *
	 */
	setColor: function() {

	},
	/**
	 *
	 */
	updateFromIRGB: function( input, newValue, oldValue ) {
		this.updateMode = 'rgb';
		var temp = this.rgbToHsv( Ext.getCmp( this.cpGetId( 'iRed' ) ).getValue(), Ext.getCmp( this.cpGetId( 'iGreen' ) ).getValue(), Ext.getCmp( this.cpGetId( 'iBlue' ) ).getValue() );
		this.HSV = { h: temp[0], s:temp[1], v:temp[2]};
		this.updateColor();
	},
	/**
	 *
	 */
	updateFromIHSV: function( input, newValue, oldValue ) {
		this.updateMode = 'hsv';
		this.HSV = { h: Ext.getCmp( this.cpGetId( 'iHue' ) ).getValue(), s:Ext.getCmp( this.cpGetId( 'iSat' ) ).getValue() / 100, v:Ext.getCmp( this.cpGetId( 'iVal' ) ).getValue() / 100};
		this.updateColor();
	},
	/**
	 *
	 */
	updateFromIHexa: function( input, newValue, oldValue ) {
		this.updateMode = 'hexa';
		var temp = this.rgbToHsv( this.hexToRgb( Ext.getCmp( this.cpGetId( 'iHexa' ) ).getValue() ) );
		this.HSV = { h: temp[0], s:temp[1], v:temp[2]};
		this.updateColor();
	},
	/**
	 *
	 */
	updateFromBox: function( event, element ) {
		this.updateMode = 'click';
		var temp = this.rgbToHsv( this.hexToRgb( Ext.get( element ).getColor( 'backgroundColor', '', '' ) ) );
		this.HSV = { h: temp[0], s:temp[1], v:temp[2]};
		this.updateColor();
	},
	/**
	 * Convert HSV color format to RGB color format
	 * @param {Integer/Array( h, s, v )} h
	 * @param {Integer} s (optional)
	 * @param {Integer} v (optional)
	 * @return {Array}
	 */
	hsvToRgb: function( h, s, v ) {
		if( h instanceof Array ) { return this.hsvToRgb.call( this, h[0], h[1], h[2] ); }
		var r, g, b, i, f, p, q, t;
	    i = Math.floor( ( h / 60 ) % 6 );
	    f = ( h / 60 ) - i;
	    p = v * ( 1 - s );
	    q = v * ( 1 - f * s );
	    t = v * ( 1 - ( 1 - f ) * s );
	    switch(i) {
	        case 0: r=v; g=t; b=p; break;
	        case 1: r=q; g=v; b=p; break;
	        case 2: r=p; g=v; b=t; break;
	        case 3: r=p; g=q; b=v; break;
	        case 4: r=t; g=p; b=v; break;
	        case 5: r=v; g=p; b=q; break;
	    }
	    return [this.realToDec( r ), this.realToDec( g ), this.realToDec( b )];
	},
	/**
	 * Convert RGB color format to HSV color format
	 * @param {Integer/Array( r, g, b )} r
	 * @param {Integer} g (optional)
	 * @param {Integer} b (optional)
	 * @return {Array}
	 */
	rgbToHsv: function( r, g, b ) {
		if( r instanceof Array ) { return this.rgbToHsv.call( this, r[0], r[1], r[2] ); }
        r = r / 255;
        g = g / 255;
        b = b / 255;
        var min, max, delta, h, s, v;
        min = Math.min( Math.min( r, g ), b );
        max = Math.max( Math.max( r, g ), b );
        delta = max - min;
        switch (max) {
            case min: h = 0; break;
            case r:   h = 60 * ( g - b ) / delta;
                      if ( g < b ) { h += 360; }
                      break;
            case g:   h = ( 60 * ( b - r ) / delta ) + 120; break;
            case b:   h = ( 60 * ( r - g ) / delta ) + 240; break;
        }
        s = ( max === 0 ) ? 0 : 1 - ( min / max );
        return [Math.round( h ), s, max];
	},
	/**
	 * Convert a float to decimal
	 * @param {Float} n
	 * @return {Integer}
	 */
	realToDec: function( n ) {
		return Math.min( 255, Math.round( n * 256 ) );
	},
	/**
	 * Convert RGB color format to Hexa color format
	 * @param {Integer/Array( r, g, b )} r
	 * @param {Integer} g (optional)
	 * @param {Integer} b (optional)
	 * @return {String}
	 */
	rgbToHex: function( r, g, b ) {
		if( r instanceof Array ) { return this.rgbToHex.call( this, r[0], r[1], r[2] ); }
		return this.decToHex( r ) + this.decToHex( g ) + this.decToHex( b );
	},
	
	/**
	 * Get the color from the internal store in RGB object format
	 * @return {Object} format: { r: redvalue, g: greenvalue, b: bluevalue }
	 */
	getRGB: function() {
		
		this.RGB=this.hsvToRgb(this.HSV)
		return this.RGB;
		
	},
	
	getHSV: function() {
		
		return this.HSV;
		
	},
	/**
	 * Convert an integer to hexa
	 * @param {Integer} n
	 * @return {String}
	 */
	decToHex: function( n ) {
		var HCHARS = '0123456789ABCDEF';
        n = parseInt(n, 10);
        n = ( !isNaN( n )) ? n : 0;
        n = (n > 255 || n < 0) ? 0 : n;
        return HCHARS.charAt( ( n - n % 16 ) / 16 ) + HCHARS.charAt( n % 16 );
	},
	/**
	 * Return with position of a character in this.HCHARS string
	 * @private
	 * @param {Char} c
	 * @return {Integer}
	 */
	getHCharPos: function( c ) {
		var HCHARS = '0123456789ABCDEF';
		return HCHARS.indexOf( c.toUpperCase() );
	},
	/**
	 * Convert a hexa string to decimal
	 * @param {String} hex
	 * @return {Integer}
	 */
	hexToDec: function( hex ) {
        var s = hex.split('');
        return ( ( this.getHCharPos( s[0] ) * 16 ) + this.getHCharPos( s[1] ) );
	},
	/**
	 * Convert a hexa string to RGB color format
	 * @param {String} hex
	 * @return {Array}
	 */
	hexToRgb: function( hex ) {
		return [ this.hexToDec( hex.substr(0, 2) ), this.hexToDec( hex.substr(2, 2) ), this.hexToDec( hex.substr(4, 2) ) ];
	},
	/**
	 * Convert Y coordinate to HUE value
	 * @private
	 * @param {Integer} y
	 * @return {Integer}
	 */
	getHue: function( y ) {
		var hue = 360 - Math.round( ( ( 181 - y ) / 181 ) * 360 );
		return hue === 360 ? 0 : hue;
	},
	/**
	 * Convert HUE value to Y coordinate
	 * @private
	 * @param {Integer} hue
	 * @return {Integer}
	 */
	getHPos: function( hue ) {
		return 181 - hue * ( 181 / 360 );
	},
	/**
	 * Convert X coordinate to Saturation value
	 * @private
	 * @param {Integer} x
	 * @return {Integer}
	 */
	getSaturation: function( x ) {
		return x / 181;
	},
	/**
	 * Convert Saturation value to Y coordinate
	 * @private
	 * @param {Integer} saturation
	 * @return {Integer}
	 */
	getSPos: function( saturation ) {
		return saturation * 181;
	},
	/**
	 * Convert Y coordinate to Brightness value
	 * @private
	 * @param {Integer} y
	 * @return {Integer}
	 */
	getValue: function( y ) {
		return ( 181 - y ) / 181;
	},
	/**
	 * Convert Brightness value to Y coordinate
	 * @private
	 * @param {Integer} value
	 * @return {Integer}
	 */
	getVPos: function( value ) {
		return 181 - ( value * 181 );
	},
	/**
	 * Not documented yet
	 */
	checkSafeNumber: function( v ) {
	    if ( !isNaN( v ) ) {
	        v = Math.min( Math.max( 0, v ), 255 );
	        var i, next;
	        for( i=0; i<256; i=i+51 ) {
	            next = i + 51;
	            if ( v>=i && v<=next ) { return ( v - i > 25 ) ? next : i; }
	        }
	    }
	    return v;
	},
	/**
	 * Not documented yet
	 */
	websafe: function( r, g, b ) {
		if( r instanceof Array ) { return this.websafe.call( this, r[0], r[1], r[2] ); }
		return [this.checkSafeNumber( r ), this.checkSafeNumber( g ), this.checkSafeNumber( b )];
	},
	/**
	 * Not documented yet
	 */
	invert: function( r, g, b ) {
		if( r instanceof Array ) { return this.invert.call( this, r[0], r[1], r[2] ); }
		return [255-r,255-g,255-b];
	}
});
/**
 *
 */
Ext.ux.ColorDialog = Ext.extend( Ext.Window, {
	initComponent: function() {
		this.width = ( !this.width || this.width < 353 ) ? 353 : this.width;
		this.applyDefaultsCP();
		Ext.ux.ColorDialog.superclass.initComponent.apply( this, arguments );
	},
	onRender: function() {
		Ext.ux.ColorDialog.superclass.onRender.apply( this, arguments );
		this.renderComponent();
	}
});
Ext.applyIf( Ext.ux.ColorDialog.prototype, Ext.ux.ColorPicker.prototype );
/**
 *
 */
Ext.ux.ColorPanel = Ext.extend( Ext.Panel, {
	initComponent: function() {
		this.width = ( !this.width || this.width < 300 ) ? 300 : this.width;
		this.applyDefaultsCP();
		Ext.ux.ColorPanel.superclass.initComponent.apply( this, arguments );
	},
	onRender: function() {
		Ext.ux.ColorPanel.superclass.onRender.apply( this, arguments );
		this.renderComponent();
	}
});
Ext.applyIf( Ext.ux.ColorPanel.prototype, Ext.ux.ColorPicker.prototype );
/**
 * Register Color* for Lazy Rendering
 */
Ext.reg( 'colorpicker', Ext.ux.ColorPicker );
Ext.reg( 'colordialog', Ext.ux.ColorDialog );
Ext.reg( 'colorpanel', Ext.ux.ColorPanel );




/**
 * Licensed under GNU LESSER GENERAL PUBLIC LICENSE Version 3
 *
 * @author Thorsten Suckow-Homberg <ts@siteartwork.de>
 * @url http://www.siteartwork.de/wizardcomponent
 */
 
/**
 * @class Ext.ux.Wiz
 * @extends Ext.Window
 *
 * A specific {@link Ext.Window} that models a wizard component.
 * A wizard is basically a dialog that guides a user through various steps
 * where he has to fill out form-data. 
 * A {@link Ext.ux.Wiz}-component consists typically of a {@link Ext.ux.Wiz.Header}
 * and window-buttons ({@link Ext.Button}) which are linked to the {@link Ext.ux.Wiz.Card}s
 * which themself represent the forms the user has to fill out.
 *
 * In order to switch between the cards in the wizard, you need the {@link Ext.ux.layout.CardLayout},
 * which will check if an active-item can be hidden, before the requested new item will be set to
 * 'active', i.e. shown. This is needed since the wizard may not allow a card to be hidden, if
 * the input entered by the user was not valid. You can get this custom layout at 
 * {@link http://www.siteartwork.de/cardlayout}.
 *
 * @constructor
 * @param {Object} config The config object 
 */ 
Ext.ux.Wiz = Ext.extend(Ext.Window, {
	
	/**
	 * @cfg {Object} An object containing the messages for the {@link Ext.LoadMask}
	 * covering the card-panel on request, whereas the property identifies the
	 * msg-text to show, and the value is the message text itself. Defaults to
	 <pre><code>
{
    default : 'Saving...'
}	 
	 </code></pre>
	 *
	 * Depending on the contexts the loadMask has to be shown in (using the method 
	 * showLoadMask of this class), the object can be configure to hold
	 * various messages.
<pre><code>
this.loadMaskConfig = {
    default    : 'Saving...',
    validating : 'Please wait, validating input...',
};	 
// loadMask will be shown, displaying the message 'Please wait, validating input...'
this.showLoadMask(true, 'validating');
	 </code></pre>	 
	 */
	loadMaskConfig : {
	    'default' : 'Enregistrement...'
	},
	
	hideAds:true,
    /**
	 * @cfg {Number} height The height of the dialog. Defaults to "400".	
	 */
    height : 550,
    
    /**
	 * @cfg {Number} width The width of the dialog. Defaults to "540".	
	 */
    width : 750,
    
    /**
	 * @cfg {Boolean} closable Wether the dialog is closable. Defaults to "true".	
	 */
	closable : true,
	
	/**
	 * @cfg {Boolean} resizable Wether the dialog is resizable. Defaults to "false".	
	 */
	resizable : false,
	
	/**
	 * @cfg {Boolean} resizable Wether the dialog is modal. Defaults to "true".	
	 */
	modal : true,  	
	
	/**
	 * @cfg {Array} cards A numeric array with the configured {@link Ext.ux.Wiz.Card}s.
	 * The index of the cards in the array represent the order in which they get displayed
	 * in the wizard (i.e. card at index 0 gets displayed in the first step, card at index 1 gets
	 * displayed in the second step and so on).
	 */
	cards : null,
	
	/**
	 * @cfg {String} previousButtonText The text to render the previous-button with.
	 * Defaults to "&lt; Back" (< Back)
	 */
	previousButtonText : '&lt; Précédent',
	
	/**
	 * @cfg {String} nextButtonText The text to render the next-button with.
	 * Defaults to "Next &gt;" (Next >)
	 */
	nextButtonText : 'Suivant &gt;',
	
	/**
	 * @cfg {String} cancelButtonText The text to render the cancel-button with.
	 * Defaults to "Cancel"
	 */
	cancelButtonText : 'Annuler',	
	
	/**
	 * @cfg {String} finishButtonText The text to render the next-button with when the last
	 * step of the wizard is reached. Defaults to "Finish"
	 */
	finishButtonText : 'Terminer',	
	
	/**
	 * @cfg {Object} headerConfig A config-object to use with {@link Ext.ux.Wiz.Header}.
	 * If not present, it defaults to an empty object.
	 */
	headerConfig : {},
	
	
	/**
	 * @cfg {Object} headerConfig A config-object to use with {@link Ext.ux.Wiz.Header}.
	 * If not present, it defaults to an empty object.
	 */
	leftPanel : {},
	
	/**
	 * @cfg {Object} cardPanelConfig A config-object to use with {@link Ext.Panel}, which
	 * represents the card-panel in this dialog.
	 * If not present, it defaults to an empty object
	 */
	cardPanelConfig : {},	
	
	/**
	 * @param {Ext.Button} The window-button for paging to the previous card.
	 * @private
	 */
	previousButton : null,
	
	/**
	 * @param {Ext.Button} The window-button for paging to the next card. When the
	 * last card is reached, the event fired by and the text rendered to this button
	 * will change.
	 * @private
	 */
	nextButton : null,
	
	/**
	 * @param {Ext.Button} The window-button for canceling the wizard. The event
	 * fired by this button will usually close the dialog.
	 * @private
	 */	
	cancelButton : null,
	
	/**
	 * @param {Ex.Panel} The card-panel that holds the various wizard cards 
	 * ({@link Ext.ux.Wiz.Card}). The card-panel itself uses the custom 
	 * {@link Ext.ux.layout.CardLayout}, which needs to be accessible by this class.
	 * You can get it at {@link http://www.siteartwork.de/cardlayout}.
	 * @private
	 */
	cardPanel : null,
	
	/**
	 * @param {Number} currentCard The current {@link Ext.ux.Wiz.Card} displayed.
	 * Defaults to -1.
	 * @private
	 */
	currentCard : -1,
	
	/**
     * @param {Ext.ux.Wiz.Header} The header-panel of the wizard. 
     * @private
     */
    headPanel : null,
    
    /**
     * @param {Number} cardCount Helper for storing the number of cards used
     * by this wizard. Defaults to 0 (inherits "cards.length" later on).
     * @private
     */
    cardCount : 0,

    /**
     * Inits this component with the specified config-properties and automatically
     * creates its components.
     */
	initComponent : function()
	{
	    this.initButtons();
	    this.initPanels();
	    
	    var title = this.title || this.headerConfig.title;
	    title     = title || "";
	    	    
	    Ext.apply(this, {
	        title     : title,
	        layout    : 'border',    
	        cardCount : this.cards.length,
		    buttons   : [
		        this.previousButton,
			    this.nextButton,
			    this.cancelButton
		    ],
		    items : [
		        this.headPanel,
		        this.leftPanel,
			    this.cardPanel
		    ]  
	    });
	    
	    this.addEvents(
            /**
             * @event cancel
             * Fires after the cancel-button has been clicked.
             * @param {Ext.ux.Wiz} this
             */   
            'cancel',
            /**
             * @event finish
             * Fires after the last card was reached in the wizard and the
             * next/finish-button has been clicked.
             * @param {Ext.ux.Wiz} this
             * @param {Object} data The collected data of the cards, whereas 
             * the index is the id of the card and the specific values
             * are objects with key/value pairs in the form formElementName : value
             */   
            'finish'
	    );
	    
		Ext.ux.Wiz.superclass.initComponent.call(this);
	},
	
// -------- helper
    /**
     * Returns the form-data of all cards in this wizard. The first index is the
     * id of the card in this wizard,
     * and the values are objects containing key/value pairs in the form of
     * fieldName : fieldValue.
     *
     * @return {Array}
     */
    getWizardData : function()
    {
        var formValues = {};
		var cards = this.cards;
		for (var i = 0, len = cards.length; i < len; i++) {
		    if (cards[i].form) {
		        formValues[cards[i].id] = cards[i].form.getValues(false);    
		    } else {
		        formValues[cards[i].id] = {};
		    }
		}
		
		return formValues;
    },
     
	/**
	 * Switches the state of this wizard between disabled/enabled.
	 * A disabled dialog will have a {@link Ext.LoadMask} covering the card-panel
	 * to prevent user input, and the buttons will be rendered disabled/enabled.
	 * If the dialog is clsable, the close-tool will be masked, too.
	 *
	 * @param {Boolean} enabled "false" to prevent user input and mask the elements,
	 * otherwise true.
	 * @param {String} type The type of msg for the {@Ext.LoadMask} covering 
	 * the cardPanel, as defined in the cfg property "loadMaskConfig"
	 */
	switchDialogState : function(enabled, type)
	{
	    this.showLoadMask(!enabled, type);
        
        this.previousButton.setDisabled(!enabled);
        this.nextButton.setDisabled(!enabled);
        this.cancelButton.setDisabled(true);
        
        if (this.closable) {
            var ct = this.tools['close'];
            switch (enabled) {
                case true:
                    this.tools['close'].unmask();			    
                break;
                
                default:
                    this.tools['close'].mask();    
                break;    
            }    
        }
	},
	
    /**
     * Shows the load mask for this wizard. By default, the cardPanel's body
     * will be masked.
     *
     * @param {Boolean} show true to show the load mask, otherwise false.
     * @param {String} type The type of message for the {@Ext.LoadMask} covering 
	 * the cardPanel, as defined in the cfg property "loadMaskConfig"
     */
    showLoadMask : function(show, type)
    {
        if (!type) {
	        type = 'default';
	    }
	    
    	if (show) {
	        if (this.loadMask == null) {
	            this.loadMask = new Ext.LoadMask(this.body);
	        } 
	        this.loadMask.msg = this.loadMaskConfig['type'];
        	this.loadMask.show();
        } else {
        	if (this.loadMask) {
        		this.loadMask.hide();	
        	}
        }
    }, 	


    /**
     * Inits the listener for the various {@link Ext.ux.Wiz.Card}s used
     * by this component.
     */
	initEvents : function()
	{
	    Ext.ux.Wiz.superclass.initEvents.call(this);
	    
		var cards = this.cards;
	
		for (var i = 0, len = cards.length; i < len; i++) {
			
			cards[i] = Ext.getCmp('card-'+i);
			cards[i].on('show', this.onCardShow, this);
			cards[i].on('hide', this.onCardHide, this);
			cards[i].on('clientvalidation', this.onClientValidation, this);
		}
	},

    /**
     * Creates the head- and the card-panel.
     * Be sure to have the custom {@link Ext.ux.layout.CardLayout} available
     * in order to make the card-panel work as expected by this component
     * ({@link http://www.siteartwork.de/cardlayout}).
     */
    initPanels : function()
    {
        var cards           = this.cards;
        var cardPanelConfig = this.cardPanelConfig;
        
        Ext.apply(this.headerConfig, {
            steps : cards.length    
        });
        
        this.headPanel = new Ext.ux.Wiz.Header(this.headerConfig);	
        
       
        this.cardPanel = new Ext.Panel({
				region : 'center',
				layout : 'card',
				style : 'margin-top: 10px',
				id : 'card-wizard-panel',
				border : false,
				activeItem : 0,
				items : cards
			});  
    }, 

    /**
     * Creates the instances for the the window buttons.
     */
    initButtons	: function()
    {
		this.previousButton = new Ext.Button({
			text 	 : this.previousButtonText,
			disabled : true,
			minWidth : 75,
			handler  : this.onPreviousClick,
			scope	 : this
		});
		
		this.nextButton = new Ext.Button({
			text	 : this.nextButtonText,
			minWidth : 75,
			handler  : this.onNextClick,
			scope	 : this
		});
		
		this.cancelButton = new Ext.Button({
			text	 : this.cancelButtonText,
			handler  : this.onCancelClick,
			scope	 : this,
			minWidth : 75		
		});
    },

// -------- listeners	
    /**
     * By default, the card firing this event monitors user input in a frequent
     * interval and fires the 'clientvalidation'-event along with it. This listener
     * will enable/disable the next/finish-button in accordance with it, based upon
     * the parameter isValid. isValid" will be set by the form validation and depends
     * on the validators you are using for the different input-elemnts in your form.
     * If the card does not contain any forms, this listener will never be called by the
     * card itself.
     *
     * @param {Ext.ux.Wiz.Card} The card that triggered the event.
     * @param {Boolean} isValid "true", if the user input was valid, otherwise
     * "false"
     */
	onClientValidation : function(card, isValid)
	{
		if (!isValid) {
			this.nextButton.setDisabled(true);	
		} else {
			this.nextButton.setDisabled(false);	
		}
	},
	
	/**
	 * This will render the "next" button as disabled since the bindHandler's delay
	 * of the next card to show might be lagging on slower systems
	 * 
	 */
	onCardHide : function(card)
	{
	    if (this.cardPanel.layout.activeItem.id === card.id) {
	        this.nextButton.setDisabled(true);	
	    }
	},
	
	
	/**
	 * Listener for the "show" event of the card that gets shown in the card-panel.
	 * Renders the next/previous buttons based on the position of the card in the wizard
	 * and updates the head-panel accordingly.
	 *
	 * @param {Ext.ux.Wiz.Card} The card being shown.
	 */
	onCardShow : function(card)
	{
		var parent = card.ownerCt;
		
		var items = parent.items;
		
		for (var i = 0, len = items.length; i < len; i++) {
			if (items.get(i).id == card.id) {
				break;	
			}	
		}
		
		this.currentCard = i;
		this.headPanel.updateStep(i, card.headtitle);
		
		if (i == len-1) {
			this.nextButton.setText(this.finishButtonText);	
		} else {
			this.nextButton.setText(this.nextButtonText);
		}
		
		
		this.nextButton.setDisabled(false);
	
				
		if (i == 0) {
			this.previousButton.setDisabled(true);
		} else {
			this.previousButton.setDisabled(false);	
		}
		
	},
	
	/**
	 * Fires the 'cancel'-event. Closes this dialog if the return value of the 
	 * listeners does not equal to "false".
	 */
	onCancelClick : function()
	{
	    if (this.fireEvent('cancel', this) !== false) {
            this.close();
        }
	},
	
	/**
	 * Fires the 'finish'-event. Closes this dialog if the return value of the 
	 * listeners does not equal to "false".
	 */
	onFinish : function()
	{
	    if (this.fireEvent('finish', this, this.getWizardData()) !== false) {
            this.close();
        }
	},	
	
	/**
	 * Listener for the previous-button. 
	 * Switches to the previous displayed {@link Ext.ux.Wiz.Card}.
	 */
	onPreviousClick : function()
	{
		if (this.currentCard > 0) {
			this.cardPanel.getLayout().setActiveItem(this.currentCard - 1);	
		}
	},
	
	/**
	 * Listener for the next-button. Switches to the next {@link Ext.ux.Wiz.Card}
	 * if the 'beforehide'-method of it did not return false. The functionality
	 * for this is implemented in {@link Ext.ux.layout.CardLayout}, which is needed
	 * as the layout for the card-panel of this component.
	 */
	onNextClick : function()
	{
		if (this.currentCard == this.cardCount-1) {
			this.onFinish();
		} else {
			this.cardPanel.getLayout().setActiveItem(this.currentCard+1);
		}
	}
});

Ext.namespace('Ext.ux.Wiz');

/**
 * Licensed under GNU LESSER GENERAL PUBLIC LICENSE Version 3
 *
 * @author Thorsten Suckow-Homberg <ts@siteartwork.de>
 * @url http://www.siteartwork.de/wizardcomponent
 */

/**
 * @class Ext.ux.Wiz.Card
 * @extends Ext.FormPanel
 *
 * A specific {@link Ext.FormPanel} that can be used as a card in a 
 * {@link Ext.ux.Wiz}-component. An instance of this card does only work properly
 * if used in a panel that uses a {@see Ext.layout.CardLayout}-layout.
 *
 * @constructor
 * @param {Object} config The config object 
 */ 
Ext.ux.Wiz.Card = Ext.extend(Ext.FormPanel, {
	
	/**
	 * @cfg {Boolean} header "True" to create the header element. Defaults to
	 * "false". See {@link Ext.form.FormPanel#header}
	 */
	header : false,
	
	/**
	 * @cfg {Strting} hideMode Hidemode of this component. Defaults to "offsets".
	 * See {@link Ext.form.FormPanel#hideMode}
	 */
	hideMode : 'display',

    initComponent : function()
    {
        this.addEvents(
        	/**
        	 * @event beforecardhide
        	 * If you want to add additional checks to your card which cannot be easily done
        	 * using default validators of input-fields (or using the monitorValid-config option), 
        	 * add your specific listeners to this event.
        	 * This event gets only fired if the activeItem of the ownerCt-component equals to
        	 * this instance of {@see Ext.ux.Wiz.Card}. This is needed since a card layout usually
        	 * hides it's items right after rendering them, involving the beforehide-event. 
        	 * If those checks would be attached to the normal beforehide-event, the card-layout 
        	 * would never be able to hide this component after rendering it, depending on the 
        	 * listeners return value.
        	 * 
        	 * @param {Ext.ux.Wiz.Card} card The card that triggered the event
        	 */
            'beforecardhide',
            'aftershow'
        );  
	
	
        Ext.ux.Wiz.Card.superclass.initComponent.call(this);
        
    },
	
// -------- helper
	isValid : function()
	{
		if (this.monitorValid) {
			return this.bindHandler();	
		}
		
		return true;
	},	
	
// -------- overrides	
    /**
     * Overrides parent implementation since we allow to add any element
     * in this component which must not be neccessarily be a form-element.
     * So before a call to "isValid()" is about to be made, this implementation
     * checks first if the specific item sitting in this component has a method "isValid"
     * to prevent errors.
     */
    bindHandler : function()
    {
        if(!this.bound){
            return false; // stops binding
        }
        var valid = true;
        this.form.items.each(function(f){
            if(f.isValid && !f.isValid(true)){
                valid = false;
                return false;
            }
        });
        if(this.buttons){
            for(var i = 0, len = this.buttons.length; i < len; i++){
                var btn = this.buttons[i];
                if(btn.formBind === true && btn.disabled === valid){
                    btn.setDisabled(!valid);
                }
            }
        }
        this.fireEvent('clientvalidation', this, valid);
    },
    
	/**
	 * Overrides parent implementation. This is needed because in case 
	 * this method uses "monitorValid=true", the method "startMonitoring" must
	 * not be called, until the "show"-event of this card fires. 
	 */
	initEvents : function()
	{
		var old = this.monitorValid;
		this.monitorValid = false;
        Ext.ux.Wiz.Card.superclass.initEvents.call(this);
		this.monitorValid = old;
		
		this.on('beforehide',     this.bubbleBeforeHideEvent, this);
		
		this.on('beforecardhide', this.isValid,    this);
	    this.on('show',           this.onCardShow, this);
		this.on('hide',           this.onCardHide, this);
    },

// -------- listener	
    /**
     * Checks wether the beforecardhide-event may be triggered.
     */
    bubbleBeforeHideEvent : function()
    {
        var ly         = this.ownerCt.layout;
        var activeItem = ly.activeItem;
        
        if (activeItem && activeItem.id === this.id) {
            return this.fireEvent('beforecardhide', this);    
        }
        
        return true;
    },

    /**
     * Stops monitoring the form elements in this component when the
     * 'hide'-event gets fired.
     */
	onCardHide : function()
	{
		if (this.monitorValid) {
			this.stopMonitoring();	
		}
	},

    /**
     * Starts monitoring the form elements in this component when the
     * 'show'-event gets fired.
     */
	onCardShow : function()
	{
	    if (this.monitorValid) {
			this.startMonitoring();	
		}
		this.fireEvent('aftershow', this);  
	}
	
});

Ext.namespace('Ext.ux.Wiz');

/**
 * Licensed under GNU LESSER GENERAL PUBLIC LICENSE Version 3
 *
 * @author Thorsten Suckow-Homberg <ts@siteartwork.de>
 * @url http://www.siteartwork.de/wizardcomponent
 */

/**
 * @class Ext.ux.Wiz.Header
 * @extends Ext.BoxComponent
 *
 * A specific {@link Ext.BoxComponent} that can be used to show the current process in an
 * {@link Ext.ux.Wiz}.
 *
 * An instance of this class is usually being created by {@link Ext.ux.Wiz#initPanels} using the
 * {@link Ext.ux.Wiz#headerConfig}-object. 
 *
 * @private
 * @constructor
 * @param {Object} config The config object 
 */ 
Ext.ux.Wiz.Header = Ext.extend(Ext.BoxComponent, {
  
    /**
     * @cfg {Number} height The height of this component. Defaults to "55".
     */  
    height : 38, 
    
    /**
     * @cfg {String} region The Region of this component. Since a {@link Ext.ux.Wiz} 
     * usually uses a {@link Ext.layout.BorderLayout}, this property defaults to
     * "north". If you want to change this property, you should also change the appropriate
     * css-classes that are used for this component.
     */  
    region : 'north', 
     
    /**
     * @cfg {String} title The title that gets rendered in the head of the component. This
     * should be a text describing the purpose of the wizard.
     */  
    title : 'Wizard',
    
    /**
     * @cfg {Number} steps The overall number of steps the user has to go through
     * to finish the wizard. 
     */
    steps : 0, 

    /**
     * @cfg {String} stepText The text in the header indicating the current process in the wizard.
     * (defaults to "Step {0} of {1}: {2}").
     * {0} is replaced with the index (+1) of the current card, {1} is replaced by the
     * total number of cards in the wizard and {2} is replaced with the title-property of the
     * {@link Ext.ux.Wiz.Card}
     * @type String
     */
    stepText : "Etape {0} sur {1} : {2}",

    /**
     * @cfg {Object} autoEl The element markup used to render this component.
     */
	autoEl : {
		tag : 'div',
		cls		 : 'ext-ux-wiz-Header',
		children : [{
		  	tag		 : 'div',
		  	cls		 : 'ext-ux-wiz-Header-title'
		}, {
			tag  : 'div',
			children : [{
				tag : 'div',
				cls : 'ext-ux-wiz-Header-step'
			}, {
				tag : 'div',
				cls : 'ext-ux-wiz-Header-stepIndicator-container'
			}]
		}]
	},

    /**
     * @param {Ext.Element}
     */
  	titleEl : null,

    /**
     * @param {Ext.Element}
     */
    stepEl  : null,
  	
    /**
     * @param {Ext.Element}
     */
  	imageContainer : null,
  	
    /**
     * @param {Array}
     */  	
  	indicators : null,
  
  	/**
  	 * @param {Ext.Template}
  	 */
  	stepTemplate : null,
  	
  	/**
  	 * @param {Number} lastActiveStep Stores the index of the last active card that
  	 * was shown-
  	 */
  	lastActiveStep : -1,
  
// -------- helper
    /**
     * Gets called by  {@link Ext.ux.Wiz#onCardShow()} and updates the header
     * with the approppriate information, such as the progress of the wizard 
     * (i.e. which card is being shown etc.)
     *
     * @param {Number} currentStep The index of the card currently shown in 
     * the wizard
     * @param {String} title The title-property of the {@link Ext.ux.Wiz.Card}
     *
     * @private
     */
  	updateStep : function(currentStep, title)
  	{
  		var html = this.stepTemplate.apply({
  			0 : currentStep+1, 
  			1 : this.steps, 
  			2 : title
  		});
  		
  		this.stepEl.update(html);
  		
  		if (this.lastActiveStep != -1) {
  			this.indicators[this.lastActiveStep].removeClass('ext-ux-wiz-Header-stepIndicator-active');
  		}
  		
  		this.indicators[currentStep].addClass('ext-ux-wiz-Header-stepIndicator-active');
  		
  		this.lastActiveStep = currentStep;
  	},
  
  
// -------- listener  
    /**
     * Overrides parent implementation to render this component properly.
     */
	onRender : function(ct, position)
	{
		Ext.ux.Wiz.Header.superclass.onRender.call(this, ct, position);
	
		this.indicators   = [];
		this.stepTemplate = new Ext.Template(this.stepText),
		this.stepTemplate.compile();
	
	    var el = this.el.dom.firstChild;
	    var ns = el.nextSibling;
	    

		this.stepEl         = new Ext.Element(ns.firstChild);
		this.imageContainer = new Ext.Element(ns.lastChild);
	

		
		var image = null;
		for (var i = 0, len = this.steps; i < len; i++) {
			image = document.createElement('div');
			image.innerHTML = "&#160;";
			image.className = 'ext-ux-wiz-Header-stepIndicator';
			this.indicators[i] = new Ext.Element(image);
			this.imageContainer.appendChild(image);
		} 
	}
});


/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
	    /**
     * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
     */
    listClass: '',
    /**
     * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
     */
    selectedClass: 'x-combo-selected',
    /**
     * @cfg {String} listAlign A valid anchor position value. See {@link Ext.Element#alignTo} for details on supported
     * anchor positions (defaults to 'tl-bl')
     */
    listAlign: 'tl-bl',
    /**
     * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
     */
    maxHeight: 300,
    /**
     * @cfg {Number} minHeight The minimum height in pixels of the dropdown list when the list is constrained by its
     * distance to the viewport edges (defaults to 90)
     */
    minHeight: 90,
    /**
     * @cfg {String} triggerAction The action to execute when the trigger field is activated.  Use 'all' to run the
     * query specified by the allQuery config option (defaults to 'query')
     */
    triggerAction: 'query',
    /**
     * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
     * (defaults to 4 if remote or 0 if local, does not apply if editable = false)
     */
    minChars : 4,
    /**
     * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
     * delay ({@link #typeAheadDelay}) if it matches a known value (defaults to false)
     */
    typeAhead: false,
    /**
     * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
     * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
     */
    queryDelay: 500,
    /**
     * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
     * filter queries will execute with page start and limit parameters.  Only applies when mode = 'remote' (defaults to 0)
     */
    pageSize: 0,
    /**
     * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus.  Only applies
     * when editable = true (defaults to false)
     */
    selectOnFocus:true,
    /**
     * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
     */
    queryParam: 'query',
    /**
     * @cfg {String} loadingText The text to display in the dropdown list while data is loading.  Only applies
     * when mode = 'remote' (defaults to 'Loading...')
     */
    loadingText: 'Loading...',
    /**
     * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
     */
    resizable: false,
    /**
     * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
     */
    handleHeight : 4,
    /**
     * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
     * traditional select (defaults to true)
     */
    editable: true,
    /**
     * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
     */
    allQuery: '',
    /**
     * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
     */
    mode: 'remote',
    /**
     * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
     * listWidth has a higher value)
     */
    minListWidth : 70,
    /**
     * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
     * allow the user to set arbitrary text into the field (defaults to false)
     */
    forceSelection:false,
    /**
     * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
     * if typeAhead = true (defaults to 250)
     */
    typeAheadDelay : 250,
    /**
     * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
     * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined). If this
     * defaut text is used, it means there is no value set and no validation will occur on this field.
     */

    /**
     * @cfg {Boolean} lazyInit True to not initialize the list for this combo until the field is focused (defaults to true)
     */
    lazyInit : true,
    initComponent : function(){
        Ext.app.SearchField.superclass.initComponent.call(this);
		      this.addEvents(
            /**
             * @event expand
             * Fires when the dropdown list is expanded
             * @param {Ext.app.SearchField} combo This combo box
             */
            'expand',
            /**
             * @event collapse
             * Fires when the dropdown list is collapsed
             * @param {Ext.app.SearchField} combo This combo box
             */
            'collapse',
            /**
             * @event beforeselect
             * Fires before a list item is selected. Return false to cancel the selection.
             * @param {Ext.app.SearchField} combo This combo box
             * @param {Ext.data.Record} record The data record returned from the underlying store
             * @param {Number} index The index of the selected item in the dropdown list
             */
            'beforeselect',
            /**
             * @event select
             * Fires when a list item is selected
             * @param {Ext.app.SearchField} combo This combo box
             * @param {Ext.data.Record} record The data record returned from the underlying store
             * @param {Number} index The index of the selected item in the dropdown list
             */
            'select',
            /**
             * @event beforequery
             * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's
             * cancel property to true.
             * @param {Object} queryEvent An object that has these properties:<ul>
             * <li><code>combo</code> : Ext.app.SearchField <div class="sub-desc">This combo box</div></li>
             * <li><code>query</code> : String <div class="sub-desc">The query</div></li>
             * <li><code>forceAll</code> : Boolean <div class="sub-desc">True to force "all" query</div></li>
             * <li><code>cancel</code> : Boolean <div class="sub-desc">Set to true to cancel the query</div></li>
             * </ul>
             */
            'beforequery'
        );
		 
		if(Ext.isArray(this.store)){
			if (Ext.isArray(this.store[0])){
				this.store = new Ext.data.SimpleStore({
				    fields: ['value','text'],
				    data: this.store
				});
		        this.valueField = 'value';
			}else{
				this.store = new Ext.data.SimpleStore({
				    fields: ['text'],
				    data: this.store,
				    expandData: true
				});
		        this.valueField = 'text';
			}
			this.displayField = 'text';
			this.mode = 'local';
		}

        this.selectedIndex = -1;
        if(this.mode == 'local'){
            if(this.initialConfig.queryDelay === undefined){
                this.queryDelay = 10;
            }
            if(this.initialConfig.minChars === undefined){
                this.minChars = 0;
            }
        }
       
    },
	onRender : function(ct, position){
        Ext.app.SearchField.superclass.onRender.call(this, ct, position);
        if(Ext.isGecko){
            this.el.dom.setAttribute('autocomplete', 'off');
        }

        if(!this.lazyInit){
            this.initList();
        }else{
            this.on('focus', this.initList, this, {single: true});
        }

        if(!this.editable){
            this.editable = true;
            this.setEditable(false);
        }
    },
	 // private
    initList : function(){
        if(!this.list){
            var cls = 'x-combo-list';

            this.list = new Ext.Layer({
                shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
            });

            var lw = this.listWidth || Math.max(this.el.getWidth()-5, this.minListWidth);
            this.list.setWidth(lw);
            this.list.swallowEvent('mousewheel');
            this.assetHeight = 0;

            if(this.title){
                this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
                this.assetHeight += this.header.getHeight();
            }

            this.innerList = this.list.createChild({cls:cls+'-inner'});
            this.innerList.on('mouseover', this.onViewOver, this);
            this.innerList.on('mousemove', this.onViewMove, this);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));

            if(this.pageSize){
                this.footer = this.list.createChild({cls:cls+'-ft'});
                this.pageTb = new Ext.PagingToolbar({
                    store:this.store,
                    pageSize: this.pageSize,
                    renderTo:this.footer
                });
                this.assetHeight += this.footer.getHeight();
            }

            if(!this.tpl){
                /**
                * @cfg {String/Ext.XTemplate} tpl The template string, or {@link Ext.XTemplate}
                * instance to use to display each item in the dropdown list. Use
                * this to create custom UI layouts for items in the list.
                * <p>
                * If you wish to preserve the default visual look of list items, add the CSS
                * class name <pre>x-combo-list-item</pre> to the template's container element.
                * <p>
                * <b>The template must contain one or more substitution parameters using field
                * names from the Combo's</b> {@link #store Store}. An example of a custom template
                * would be adding an <pre>ext:qtip</pre> attribute which might display other fields
                * from the Store.
                * <p>
                * The dropdown list is displayed in a DataView. See {@link Ext.DataView} for details.
                */
                this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
                /**
                 * @cfg {String} itemSelector
                 * <b>This setting is required if a custom XTemplate has been specified in {@link #tpl}
                 * which assigns a class other than <pre>'x-combo-list-item'</pre> to dropdown list items</b>.
                 * A simple CSS selector (e.g. div.some-class or span:first-child) that will be
                 * used to determine what nodes the DataView which handles the dropdown display will
                 * be working with.
                 */
            }

            /**
            * The {@link Ext.DataView DataView} used to display the ComboBox's options.
            * @type Ext.DataView
            */
            this.view = new Ext.DataView({
                applyTo: this.innerList,
                tpl: this.tpl,
                singleSelect: true,
                selectedClass: this.selectedClass,
                itemSelector: this.itemSelector || '.' + cls + '-item'
            });

            this.view.on('click', this.onViewClick, this);

            this.bindStore(this.store, true);

            if(this.resizable){
                this.resizer = new Ext.Resizable(this.list,  {
                   pinned:true, handles:'se'
                });
                this.resizer.on('resize', function(r, w, h){
                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
                    this.listWidth = w;
                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
                    this.restrictHeight();
                }, this);
                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
            }
        }
    },

    // private
    bindStore : function(store, initial){
        if(this.store && !initial){
            this.store.un('beforeload', this.onBeforeLoad, this);
            this.store.un('load', this.onLoad, this);
            this.store.un('loadexception', this.collapse, this);
            if(!store){
                this.store = null;
                if(this.view){
                    this.view.setStore(null);
                }
            }
        }
        if(store){
            this.store = Ext.StoreMgr.lookup(store);

            this.store.on('beforeload', this.onBeforeLoad, this);
            this.store.on('load', this.onLoad, this);
            this.store.on('loadexception', this.collapse, this);

            if(this.view){
                this.view.setStore(store);
            }
        }
    },

    // private
    initEvents : function(){
        Ext.app.SearchField.superclass.initEvents.call(this);

        this.keyNav = new Ext.KeyNav(this.el, {
            "up" : function(e){
                this.inKeyMode = true;
                this.selectPrev();
            },

            "down" : function(e){
                if(!this.isExpanded()){
                    this.onTriggerClick();
                }else{
                    this.inKeyMode = true;
                    this.selectNext();
                }
            },

            "esc" : function(e){
                this.collapse();
            },
            scope : this,

            doRelay : function(foo, bar, hname){
                if(hname == 'down' || this.scope.isExpanded()){
                   return Ext.KeyNav.prototype.doRelay.apply(this, arguments);
                }
                return true;
            }
        });
        this.queryDelay = Math.max(this.queryDelay || 10,
                this.mode == 'local' ? 10 : 250);
        this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
        if(this.typeAhead){
            this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
        }
        if(this.editable !== false){
            this.el.on("keyup", this.onKeyUp, this);
        }
        if(this.forceSelection){
            this.on('blur', this.doForce, this);
        }
		
	
	
    },

    // private
    onDestroy : function(){
        if(this.view){
            this.view.el.removeAllListeners();
            this.view.el.remove();
            this.view.purgeListeners();
        }
        if(this.list){
            this.list.destroy();
        }
        this.bindStore(null);
        Ext.app.SearchField.superclass.onDestroy.call(this);
    },


    // private
    unsetDelayCheck : function(){
        delete this.delayedCheck;
    },

    // private
    fireKey : function(e){
		
		var v = this.getRawValue();
		
		if (v.length > 0) {
			var key =e.getKey()
			if(key == e.ENTER){  
				this.onViewClick();
			 	
			 }	 
			            
		   
			this.hasSearch = true;
		    this.triggers[0].show();
       }
			 
			 
        if(e.isNavKeyPress() && !this.isExpanded() && !this.delayedCheck){
            this.fireEvent("specialkey", this, e);
        }
    },
	
	    // private
    onResize: function(w, h){
        Ext.app.SearchField.superclass.onResize.apply(this, arguments);
        if(this.list && this.listWidth === undefined){
            var lw = Math.max(w, this.minListWidth);
            this.list.setWidth(lw);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
        }
    },
	
	   // private
    onBeforeLoad : function(){
        if(!this.hasFocus){
            return;
        }
        this.innerList.update(this.loadingText ?
               '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
        this.restrictHeight();
        this.selectedIndex = -1;
    },


    // private
    onTypeAhead : function(){
        if(this.store.getCount() > 0){
            var r = this.store.getAt(0);
            var newValue = r.data[this.displayField];
            var len = newValue.length;
			var value = this.getRawValue();
            var selStart = value.length;
            if(selStart != len ){
                this.setRawValue(newValue);
                this.selectText(selStart, newValue.length);
            }
        }
    },

    // private
    onSelect : function(record, index){
        if(this.fireEvent('beforeselect', this, record, index) !== false){
            this.setValue(record.data[this.valueField || this.displayField]);
            this.collapse();
            this.fireEvent('select', this, record, index);			 
        }
    },

    /**
     * Returns the currently selected field value or empty string if no value is set.
     * @return {String} value The selected value
     */
    getValue : function(){
        if(this.valueField){
            return typeof this.value != 'undefined' ? this.value : '';
        }else{
            return Ext.app.SearchField.superclass.getValue.call(this);
        }
    },

    /**
     * Clears any text/value currently set in the field
     */
	
	setEmptyText:function(value){
		
		
			this.emptyText =value;
			this.setRawValue('');
       		this.lastSelectionText = '';
			this.blur();
			this.applyEmptyText();
		
        
		
	},
    clearValue : function(){
        if(this.hiddenField){
            this.hiddenField.value = '';
        }
        this.setRawValue('');
        this.lastSelectionText = '';
        this.applyEmptyText();
		
        this.value = '';
    },

    /**
     * Sets the specified value into the field.  If the value finds a match, the corresponding record text
     * will be displayed in the field.  If the value does not match the data value of an existing item,
     * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
     * Otherwise the field will be blank (although the value will still be set).
     * @param {String} value The value to match
     */
    setValue : function(v){
        var text = v;
        if(this.valueField){
            var r = this.findRecord(this.valueField, v);
            if(r){
                text = r.data[this.displayField];
				this.onTrigger2Click();
            }else if(this.valueNotFoundText !== undefined){
                text = this.valueNotFoundText;
            }
        }
        this.lastSelectionText = text;
        if(this.hiddenField){
            this.hiddenField.value = v;
        }
        Ext.app.SearchField.superclass.setValue.call(this, text);
        this.value = v;
    },

    // private
    findRecord : function(prop, value){
       if (value !== undefined) {
	   
	   	var record;
	   	if (this.store.getCount() > 0) {
	   		this.store.each(function(r){
	   			if (r.data[prop].toLowerCase() == value.toLowerCase()) {
	   				record = r;
	   				return false;
	   			}
	   		});
	   	}
	   	return record;
	   }
    },

    // private
    onViewMove : function(e, t){
        this.inKeyMode = false;
    },

    // private
    onViewOver : function(e, t){
        if(this.inKeyMode){ // prevent key nav and mouse over conflicts
            return;
        }
        var item = this.view.findItemFromChild(t);
        if(item){
            var index = this.view.indexOf(item);
			 this.view.select(index);
        }
    },

    // private
    onViewClick : function(doFocus){
        var index = this.view.getSelectedIndexes()[0];
        var r = this.store.getAt(index);
        if(r){
            this.onSelect(r, index);
        }
        if(doFocus !== false){
            this.el.focus();
        }
		this.onTrigger2Click();
    },

    // private
    restrictHeight : function(){
        this.innerList.dom.style.height = '';
        var inner = this.innerList.dom;
        var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight;
        var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
        var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;
        var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;
        var space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
        h = Math.min(h, space, this.maxHeight);

        this.innerList.setHeight(h);
        this.list.beginUpdate();
        this.list.setHeight(h+pad);
        this.list.alignTo(this.wrap, this.listAlign);
        this.list.endUpdate();
    },

    // private
    onEmptyResults : function(){
        this.collapse();
    },

    /**
     * Returns true if the dropdown list is expanded, else false.
     */
    isExpanded : function(){
        return this.list && this.list.isVisible();
    },

    /**
     * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
     * @param {String} value The data value of the item to select
     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
     * selected item if it is not currently in view (defaults to true)
     * @return {Boolean} True if the value matched an item in the list, else false
     */
    selectByValue : function(v, scrollIntoView){
        if(v !== undefined && v !== null){
            var r = this.findRecord(this.valueField || this.displayField, v);
            if(r){
                this.select(this.store.indexOf(r), scrollIntoView);
                return true;
            }
        }
        return false;
    },

    /**
     * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
     * @param {Number} index The zero-based index of the list item to select
     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
     * selected item if it is not currently in view (defaults to true)
     */
    select : function(index, scrollIntoView){
        this.selectedIndex = index;
        this.view.select(index);
        if(scrollIntoView !== false){
            var el = this.view.getNode(index);
            if(el){
                this.innerList.scrollChildIntoView(el, false);
            }
        }
    },

    // private
    selectNext : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex < ct-1){
                this.select(this.selectedIndex+1);
            }
        }
    },

    // private
    selectPrev : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex != 0){
                this.select(this.selectedIndex-1);
            }
        }
    },

    // private
    onKeyUp : function(e){
        if(this.editable !== false && !e.isSpecialKey()){
            this.lastKey = e.getKey();
            this.dqTask.delay(this.queryDelay);			
        }
    },

    // private
    validateBlur : function(){
        return !this.list || !this.list.isVisible();
    },

    // private
    initQuery : function(){
        this.doQuery(this.getRawValue());
    },

    // private
    doForce : function(){
        if(this.el.dom.value.length > 0){
            this.el.dom.value =
                this.lastSelectionText === undefined ? '' : this.lastSelectionText;
            this.applyEmptyText();
        }
    },

    /**
     * Execute a query to filter the dropdown list.  Fires the {@link #beforequery} event prior to performing the
     * query allowing the query action to be canceled if needed.
     * @param {String} query The SQL query to execute
     * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
     * in the field than the minimum specified by the minChars config option.  It also clears any filter previously
     * saved in the current store (defaults to false)
     */

    doQuery : function(q, forceAll){
        if(q === undefined || q === null){
            q = '';
        }
        var qe = {
            query: q,
            forceAll: forceAll,
            combo: this,
            cancel:false
        };
        if(this.fireEvent('beforequery', qe)===false || qe.cancel){
            return false;
        }
        q = qe.query;
        forceAll = qe.forceAll;
        if(forceAll === true || (q.length >= this.minChars)){
            if(this.lastQuery !== q){
                this.lastQuery = q;
                if(this.mode == 'local'){
                    this.selectedIndex = -1;
                    if(forceAll){
                        this.store.clearFilter();
                    }else{
                        this.store.filter(this.displayField, q);
                    }
				
						this.onLoad();
				
                }else{
                    this.store.baseParams[this.queryParam] = q;
                    this.store.load({
                        params: this.getParams(q)
                    });
					
					
						this.expand();
					
                }
            }else{
                this.selectedIndex = -1;
                this.onLoad();
            }
        }
    },


    // private
    getParams : function(q){
        var p = {};
        //p[this.queryParam] = q;
        if(this.pageSize){
            p.start = 0;
            p.limit = this.pageSize;
        }
        return p;
    },

    /**
     * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.
     */
    collapse : function(){
        
        this.list.hide();
        Ext.getDoc().un('mousewheel', this.collapseIf, this);
        Ext.getDoc().un('mousedown', this.collapseIf, this);
        this.fireEvent('collapse', this);
    },

    // private
    collapseIf : function(e){
        if(!e.within(this.wrap) && !e.within(this.list)){
            this.collapse();
        }
    },

    /**
     * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.
     */
    expand : function(){
        if(this.isExpanded() || !this.hasFocus){
            return;
        }
        this.list.alignTo(this.wrap, this.listAlign);
        this.list.show();
        this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac
        Ext.getDoc().on('mousewheel', this.collapseIf, this);
        Ext.getDoc().on('mousedown', this.collapseIf, this);
        this.fireEvent('expand', this);
    },	//Configuration de la combobox
     

    
    // private
    onLoad : function(){
        if(!this.hasFocus){
            return;
        }
        		
        if (this.store.getCount() > 0 && this.el.dom.value!='') {
		
			this.expand();
			this.restrictHeight();
			
		}
		// si le store est vide on dit qu'il n'y a pas de résultats
		else {
			this.collapse();
		}		
		
    },


    

	handler:function(){
		
	},
    trigger1Class:'x-form-clear-trigger',
    trigger2Class:'x-form-search-trigger',
    hideTrigger1:true,
    width:180,
    hasSearch : false,
    paramName : 'query',

    onTrigger1Click : function(){
        if(this.hasSearch){
            this.el.dom.value = '';
			this.el.focus();
            var o = {start: 0};            
            this.triggers[0].hide();
            this.hasSearch = false;
        }
    },

    onTrigger2Click : function(){
		
        var v = this.getRawValue();
        if(v.length < 1){
            this.onTrigger1Click();
            return;
        }
        var o = {start: 0};
        this.hasSearch = true;
        this.triggers[0].show();
		this.handler();
		 this.collapse();
		
		    }
});Ext.SimpleButton = Ext.extend(Ext.Button, {
	template: new Ext.Template('<div><div onclick="this.blur()" class="simpleButton">', '<em unselectable="on"><div class="x-btn-text" type="{1}">{0}</div></em>', "</div></div>"),
	buttonSelector: ".x-btn-text"
});
Ext.reg('sbutton', Ext.SimpleButton);

Ext.DivButton = Ext.extend(Ext.Button, {
	template: new Ext.Template('<table  onclick="this.blur()" border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>', '<td class="x-btn-left"><i>&#160;</i></td><td class="x-btn-center"><em unselectable="on"><div class="x-btn-text" type="{1}">{0}</div></em></td><td class="x-btn-right"><i>&#160;</i></td>', "</tr></tbody></table>"),
	buttonSelector: ".x-btn-text"
});
Ext.reg('dbutton', Ext.DivButton);

Ext.ButtonVolume = Ext.extend(Ext.Button, {
	template: new Ext.Template('<div onclick="this.blur()" class="simpleButton">', '<div class="volume-wrapper"><em unselectable="on"><div class="x-btn-text" type="{1}">{0}<div class="volume-current"></div></div></em></div>', "</div>"),
	buttonSelector: ".x-btn-text",
	_value: 0,
	_maxWidth: 0,
	
	afterRender: function() {
		Ext.ButtonVolume.superclass.afterRender.call(this);
		this._volumeWrapper = this.el.child(".volume-wrapper");
		this._maxWidth = this._volumeWrapper.getWidth() - 10;
	},
	// private

	onClick: function(e) {
		if (e) {
			e.preventDefault();
		}
		if (e.button != 0) {
			return;
		}
		if (!this.disabled) {
			var left = this._volumeWrapper.getLeft();
			var width = e.xy[0] - left;
			this._value = width / this._maxWidth;
			if (this._value > 1) {
				this._value = 1;
			} else if (this._value < 0) {
				this._value = 0;
			}
			this.el.child(this.buttonSelector).setWidth(width, true);
			
			this.fireEvent("click", this, this._value, e);
			if (this.handler) {
				//this.el.removeClass("x-btn-over");
				this.handler.call(this.scope || this, this, this._value, e);
			}
			
		}
		
	},
	setValue: function(v) {
		var width = v * this._maxWidth;
		this._value = v;
		this.el.child(this.buttonSelector).setWidth(width, true);
		
	},
	getValue: function() {
		return this._value;
	}
});

Ext.reg('vbutton', Ext.ButtonVolume);
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();J.Language = function(){

    return {
        init: function(){
            // Language gestion
            J.CookieProvider = new Ext.state.CookieProvider({
                expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 30)) // 30 days
            });
            this.languageCode = J.CookieProvider.get("languageCode");
            
            if (!this.languageCode) {
                var languages = ["en", "fr"];
                var lang = navigator.language ? navigator.language : navigator.userLanguage;
                
                var host = window.location.host;
                
                // Get language from hostname
                if (host === "www.jiwa.fr") {
                    this.languageCode = "fr";
                }
                
                // Otherwise get language from browser
                for (var i = 0; i < languages.length; i++) {
                    var l = lang.substr(0, 2);
                    if (l === 'fr') {
                       this.languageCode = 'fr';
                        break;
                    }
                }
                
                if (!this.languageCode) {
                    this.languageCode = "en";
                }
            }
            
			
			
            J.CookieProvider.set("languageCode", J.Language.languageCode);
			
			if(J.Language.languageCode == 'en'){
				J.languageId= 0;
			}else{
				J.languageId= 1;
			}
           
        },
       
        force: function(lang){
            J.CookieProvider.set("languageCode", lang);
			document.location = '#home';
            window.location.reload();
        }
    };
}
();



Ext.Ajax.defaultHeaders = {
    "Accept-Charset": "utf-8;q=0.7,*;q=0.7"
};

Ext.Ajax.timeout = 60000;

Ext.jwDecode = function(options, success, response){
    var json = null;
    var error = !success;
    response = response ||
    {};
    options = options ||
    {};
    
    if (J.fc.multipleRequest.length == 0) {
        Ext.Msg.hide();
    }
    
    if (success) {
        try {
            json = Ext.decode(response.responseText);
            json.success = json.success == false ? false : true;
        } 
        catch (e) {
            json = {
                statusText: "Unable to undersand response text",
                status: "301",
                success: false,
                fatalError: true
            };
        }
    }
    else {
        json = response;
        json.success = false;
        json.fatalError = true;
    }
    
    if (json.errors) {
        console.error("Error " + json.status + " while getting " + options.url + " : \"" + json.statusText + "\"", response.responseText);
   			
   
    }
    
    return json;
};


/**
 * @author admin
 */

Ext.form.Field.prototype.msgTarget = 'side';

Ext.form.ConfirmTextField = function(config){
	Ext.form.TextField.superclass.constructor.call(this, config);
};

Ext.extend(Ext.form.ConfirmTextField, Ext.form.TextField,  {
	confirmFieldText : "This should be equal to the {0} field",
	confirmField : null,
	
	validateValue : function(value){
		
		if(value.length < 1 || value === this.emptyText){ 
             if(this.allowBlank){
                 this.clearInvalid();
                 return true;
             }else{
                 this.markInvalid(this.blankText);
                 return false;
             }
		}
		if(value != this.confirmField.getRawValue()){
			this.markInvalid(String.format(this.confirmFieldText, this.confirmField.getName()));
			return false;
		}
		return true;
	}	
});
Ext.form.CheckboxValidatable = function(config){
	Ext.form.Checkbox.superclass.constructor.call(this, config);
};


Ext.extend(Ext.form.CheckboxValidatable, Ext.form.Checkbox,  {
	
	markInvalid: function(msg) {
		 switch(this.msgTarget){
            case 'qtip':
                this.el.dom.qtip = msg;
                this.el.dom.qclass = 'x-form-invalid-tip';
                if(Ext.QuickTips){ // fix for floating editors interacting with DND
                    Ext.QuickTips.enable();
                }
                break;
            case 'title':
                this.el.dom.title = msg;
                break;
            case 'under':
                if(!this.errorEl){
                    var elp = this.el.findParent('.x-form-element', 5, true);
                    this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
                    this.errorEl.setWidth(elp.getWidth(true)-20);
                }
                this.errorEl.update(msg);
                Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
                break;
            case 'side':
                if(!this.errorIcon){
                    var elp = this.el.findParent('.x-form-element', 5, true);
                    this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
                }
                this.alignErrorIcon();
                this.errorIcon.dom.qtip = msg;
                this.errorIcon.dom.qclass = 'x-form-invalid-tip';
                this.errorIcon.show();
                this.on('resize', this.alignErrorIcon, this);
                break;
            default:
                var t = Ext.getDom(this.msgTarget);
                t.innerHTML = msg;
                t.style.display = this.msgDisplay;
                break;
        }
        this.fireEvent('invalid', this, msg);
    },
    
   clearInvalid : function(){
        if(!this.rendered || this.preventMark){ // not rendered
            return;
        }
        this.el.removeClass(this.invalidClass);
        switch(this.msgTarget){
            case 'qtip':
                this.el.dom.qtip = '';
                break;
            case 'title':
                this.el.dom.title = '';
                break;
            case 'under':
                if(this.errorEl){
                    Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
                }
                break;
            case 'side':
                if(this.errorIcon){
                    this.errorIcon.dom.qtip = '';
                    this.errorIcon.hide();
                    this.un('resize', this.alignErrorIcon, this);
                }
                break;
            default:
                var t = Ext.getDom(this.msgTarget);
                t.innerHTML = '';
                t.style.display = 'none';
                break;
        }
        this.fireEvent('valid', this);
    }
	
});
// ———-
Ext.form.SelectField = function(config){
	Ext.form.TextField.superclass.constructor.call(this, config);
};
Ext.extend(Ext.form.SelectField, Ext.form.TextField,  {
	defaultAutoCreate : {tag: "select"},
	data: null,
	emptyText: '',
	
	// private
	onRender : function(ct, position){
		Ext.form.SelectField.superclass.onRender.call(this, ct, position);
		if(this.data) {
			for(var key in this.data) {
				var value = this.data[key];
				if(typeof(value)== 'function') {
					continue;
				}
				var selected = (key==this.value);
				this.el.dom.options.add(new Option(value, key, false, selected));
				continue;
				
				if(key==this.value) {
//					var a = this.el.createChild({tag: 'option', value: key, html: value, selected: true});					
				} else {
//					var a =this.el.createChild({tag: 'option', value: key, html: value});
				}
			}
		}
		// if(this.value) {
		// 	this.setValue(this.value);
		// } else {
		// 	this.value = '';
		// 	this.setValue('');			
		// }
	},
	
	validateValue : function(value){
		if(value.length<1 || value === this.emptyText){ // if it's blank
	        if(this.allowBlank){
	            this.clearInvalid();
	            return true;
	        }else{
	            this.markInvalid(this.blankText);
	            return false;
	        }
		}
		return true;
	},
	setValue : function(v) {
		if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){
			this.el.removeClass(this.emptyClass);
		}
		Ext.form.TextField.superclass.setValue.apply(this, arguments);
		this.applyEmptyText();
		this.autoSize();
	}
});


Ext.form.DivField = function(config){
	Ext.form.TextField.superclass.constructor.call(this, config);
};
Ext.extend(Ext.form.DivField, Ext.form.Field,  {
	defaultAutoCreate : {tag: "div", value: ''},
	data: null,
	emptyText: '',
	
	// private
	onRender : function(ct, position){
		Ext.form.DivField.superclass.onRender.call(this, ct, position);
		this.el.createChild(this.value);
	},
	
	validateValue : function(value){
		return true;
	},
	setValue : function(v) {
		
	}
});

Ext.form.BasicForm.override({
    markInvalid : function(errors){
        if(Ext.isArray(errors)){
            for(var i = 0, len = errors.length; i < len; i++){
                var fieldError = errors[i];
                var f = this.findField(fieldError.id);
				fieldError.msg =tr(fieldError.msg);
                if(f){
                    f.markInvalid(fieldError.msg);
                }
            }
        }else{
            var field, id;
            for(id in errors){
	
                if(typeof errors[id] != 'function' && (field = this.findField(id))){
                    errors[id] =tr(errors[id]);
					field.markInvalid(errors[id]);
                }
            }
        }
        return this;
    }
});


  
/**
 * @author admin
 */

Ext.grid.GridView.override({
    syncFocus: false,
	ads:false,
    focusCell: function(row, col, hscroll){
		row = Math.min(row, Math.max(0, this.getRows().length-1));
        var xy = this.ensureVisible(row, col, hscroll);
      	//  this.focusEl.setXY(xy||this.scroller.getXY());
   		// this.scroller.dom.scrollTop = 0;
    },
	getAds: function(){
    
				var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=h&language="+J.Language.languageCode+"&urlContent="+url+"&name="+J.fc.name;
				
				return '<iframe  WIDTH="100%"  height="65" SRC="' + srcBan + '" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ></iframe>';
				
				
    
    },
	// private
    initTemplates : function(){
        var ts = this.templates || {};
        if(!ts.master){
            ts.master = new Ext.Template(
                    '<div class="x-grid3" hidefocus="true">',
                        '<div class="x-grid3-viewport">',
                            '<div class="x-grid3-header" ><div class="x-grid3-header-inner"><div class="x-grid3-header-offset">{header}</div></div><div class="x-clear"></div></div>',
                            '<div class="x-grid3-scroller"><div class="x-grid3-body">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
                        "</div>",
                        '<div class="x-grid3-resize-marker">&#160;</div>',
                        '<div class="x-grid3-resize-proxy">&#160;</div>',
                    "</div>"
                    );
        }

        if(!ts.header){
           if (this.ads) {
		   	
			ts.header = new Ext.Template('<table border="0" cellspacing="0"  width="100%" cellpadding="0" >', 
			'<tr><td class="pub-google-grid" >'+this.getAds()+'<td></tr>',
			 "</table>",
			  '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle};">', 
			  '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
			   "</table>");
		   }else{
		  			ts.header = new Ext.Template(
			  '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle};">', 
			  '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
			   "</table>");
		   }
        }

        if(!ts.hcell){
            ts.hcell = new Ext.Template(
                    '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id}" style="{style}"><div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
                    '{value}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
                    "</div></td>"
                    );
        }

        if(!ts.body){
            ts.body = new Ext.Template('{rows}');
        }

        if(!ts.row){
            ts.row = new Ext.Template(
                    '<div class="x-grid3-row {alt}" style="{tstyle}"><table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
                    '<tbody><tr>{cells}</tr>',
                    (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
                    '</tbody></table></div>'
                    );
        }

        if(!ts.cell){
            ts.cell = new Ext.Template(
                    '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
                    '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
                    "</td>"
                    );
        }

        for(var k in ts){
            var t = ts[k];
            if(t && typeof t.compile == 'function' && !t.compiled){
                t.disableFormats = true;
                t.compile();
            }
        }

        this.templates = ts;
        this.colRe = new RegExp("x-grid3-td-([^\\s]+)", "");
    }
    
});

Ext.DataView.override({ 
	autoHeight :true,
	ads:true,
	getAds: function(){
   
			var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=h&image=true&language="+J.Language.languageCode+"&urlContent="+url+"&name="+J.fc.name;
				
				return '<iframe  WIDTH="100%"  height="65" SRC="' + srcBan + '" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ></iframe>';
			
		
    
    },
	onRender : function(ct,position){
        if(!this.el){
            this.el = document.createElement('div');
            this.el.id = this.id;
        }
		
	
		 
	if (this.ads) {
		ct.createChild({
			cls: "pub-google-list",
			html: this.getAds()
		});
		
	}
		
		
        Ext.DataView.superclass.onRender.apply(this, arguments);
    }
});

Ext.Panel.override({
    autoDestroy :true,
	bufferResize :false,
	monitorResize :false
});



Ext.Window.override({
    autoDestroy :true,
	bufferResize :false,
	monitorResize :false
});
  /**
 * @author admin
 */



Ext.MessageBox.wait = function(msg, title, config){
    this.show({
        title: title,
        msg: msg,
        buttons: false,
        closable: true,
        wait: true,
        modal: true,
        minWidth: this.minProgressWidth,
        waitConfig: config
    });
    return this;
};



Ext.Msg.wait = Ext.MessageBox.wait;


Ext.MessageBox.progress = function(title, msg, progressText){
    this.show({
        title: title,
        msg: msg,
        buttons: false,
        progress: true,
        closable: true,
        minWidth: this.minProgressWidth,
        progressText: progressText
    });
    return this;
};
Ext.override(Ext.Button, {
    // private
    autoWidth: function() {
        if (this.el) {
            this.el.setWidth("auto");
            if (Ext.isIE7 && Ext.isStrict) {
                var ib = this.el.child(this.buttonSelector);
                if (ib && ib.getWidth() > 20 && this.text) {
                    ib.clip();
                    ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width + ib.getFrameWidth('lr'));
                }
            }
            if (this.minWidth) {
                if (this.el.getWidth() < this.minWidth) {
                    this.el.setWidth(this.minWidth);
                }
            }
        }
    }
});



Ext.convert = function(v, type, options) {
	options = options || {};
	var stripRe = /[\$,%]/g;
	var cv, dateFormat = this.dateFormat;
	
	switch (type) {
	case "string":
		return (v === undefined || v === null) ? '' : String(v);
		break;
	case "int":
		return v !== undefined && v !== null && v !== '' ? parseInt(String(v).replace(stripRe, ""), 10) : '';
		break;
	case "float":
		return v !== undefined && v !== null && v !== '' ? parseFloat(String(v).replace(stripRe, ""), 10) : '';
		break;
	case "bool":
	case "boolean":
		return (v === true || v === "true" || v == 1|| v == '1');
		break;
	case "date":
		if (!v) {
			return '';
		}
		if (Ext.isDate(v)) {
			return v;
		}
		if (options.dateFormat) {
			if (options.dateFormat == "timestamp") {
				return new Date(v * 1000);
			}
			if (options.dateFormat == "time") {
				return new Date(parseInt(v, 10));
			}
			return Date.parseDate(v, options.dateFormat);
		}
		var parsed = Date.parse(v);
		return parsed ? new Date(parsed) : null;
		break;
	}
	return v;
};

jTr = function(key, user) {
    var value = T[key];
    if (value === undefined) {
        console.warn("UNKNOWN KEY", key, arguments);
        J.TranslationErrors[key] = key;
        return "" + key + "";
    }
    var sex = user.sex;
    
    if (value[sex]) {
        value = value[sex];
    } else {
    }
    if (arguments.length == 2) {
        return String.format(value, user.userName);
    } else if (arguments.length == 3) {
        return String.format(value, user.userName, arguments[2]);
    } else if (arguments.length == 4) {
        return String.format(value, user.userName, arguments[2], arguments[3]);
    } else if (arguments.length == 5) {
        return String.format(value, user.userName, arguments[2], arguments[3], arguments[4]);
    }
};


tr = function(key) {
    var value = T[key];
   
    if (value === undefined) {
        console.warn("UNKNOWN KEY", key, arguments);
        J.TranslationErrors[key] = key;
        return "" + key + "";
    } else if (arguments.length == 0) {
        return key;
    } else {
        var beg = 1;
        if (value["s"] !== undefined) {
            if (arguments[beg] > 1) {
                value = value['p'];
            } else {
                value = value['s'];
            }
        }
        if (arguments.length == beg) {
            return value;
        } else if (arguments.length == beg + 1) {
            return String.format(value, arguments[beg]);
        } else if (arguments.length == beg + 2) {
            return String.format(value, arguments[beg], arguments[beg + 1]);
        } else if (arguments.length == beg + 3) {
            return String.format(value, arguments[beg], arguments[beg + 1], arguments[beg + 2]);
        }
    }
};


fTr = function(key) {
    var value = T[key];
    
    if (value === undefined) {
        J.TranslationErrors[key] = key;
        console.warn("UNKNOWN KEY", key, arguments);
        return "abcdefghijklmnopqrstuvwxyz";
    } else {
        return value;
    }
};

// Translate an array
aTr = function(arrayName, keyName) {
    var array = T[arrayName];
    if (array === undefined) {
        J.TranslationErrors[arrayName] = keyName;
        console.warn("UNKNOWN ARRAY", arguments);
        return "" + arrayName + "";
    }
    var value = array[keyName];
    if (value === undefined) {
        J.TranslationErrors[arrayName + "[" + keyName + "]"] = keyName;
        console.warn("UNKNOWN KEY IN ARRAY", arguments);
        return "" + arrayName + '[' + keyName + ']' + "";
    }
    return value;
};

arrTr = function(key) {
    var value = T[key];
    if (value === undefined) {
        J.TranslationErrors[key] = key;
        console.warn("UNKNOWN ARRAY", arguments);
        return [];
    }
    return value;
};




J.TranslationErrors = {};

/*Ext.override(Ext.Toolbar, {
    add: Ext.Toolbar.superclass.add
});
*/
J.Bar = Ext.extend (Ext.StatusBar, {
    // private
    afterRender : function(){
        J.Bar.superclass.afterRender.call(this);
        

		
        var right = this.statusAlign=='right',
            td = Ext.get(this.nextBlock());
        
        if(right){
            this.tr.appendChild(td.dom);
        }else{
            td.insertBefore(this.tr.firstChild);
        }
        
		this.left = td.createChild( {html :'<table class="player-button" cellspacing="0"><tr></tr></table>'});
        this.trLeft = this.left.child("tr", true);

        this.spacerEl = td.insertSibling({
            tag: 'td',
            style: 'width:100%',
			cls:'ytb-spacer'
        }, right ? 'before' : 'after');
		
		this.table = this.container.child('table',true);
		this.line = this.el.createChild({
            tag: 'div',
			cls:'player-bar-line',
			children :[{
				tag: 'div',
				style: 'width:100%',
				children: {
					id: 'player-bar-progress',
					html: '<div  id="player-bar-inner-progress"><div id="player-bar-progress-past"></div><div id="player-bar-progress-current"></div><div id="player-bar-progress-future"></div></div>'
				
				}
			}]
        },this.table);
		
    }, 

	 nextBlock : function(){
	 	

        var td = document.createElement("td");
       
	   	if(this.left){
			this.trLeft.appendChild(td);
		
		}else{
				 this.tr.appendChild(td);
		}
		
        return td;
    }
});
J.Popup = function(p){

    p = p ||
    {};
    
    p.title = p.title || "TODO: TITLE";
    p.request = p.request || false;
    if (p.request) {
        p.request.url = p.request.url || "/todo/requestUrl";
        p.request.params = p.request.params ||
        {};
    }
    p.obj = p.obj ||
    {};
    p.submit = p.submit ||
    {};
    p.submit.url = p.submit.url || "/todo/submitUrl";
    p.submit.params = p.submit.params ||
    {};
    p.armEnter = (p.armEnter === false) ? false : true;
    this.tiny = false;
    if (p.onSubmit) {
        this.onSubmit = p.onSubmit;
    }
    p.fileUpload = p.fileUpload || false;
    
    p.fields = p.fields || [];
    
    // Ext.apply(this, p);
    this.p = p;
    
    this.successCallback = p.success;
    this.failureCallback = p.failure;
    
    if (p.buttons == undefined) {
        p.buttons = [{
            text: tr('popup_button_ok').bold(),
            handler: this.onSubmit,
            scope: this
        }, {
            text: tr('popup_button_close'),
            handler: this.onClose,
            scope: this
        }];
    }
    
    
    var width = this.p.big ? 725 : 555;
    
    if (this.p.right) {
    
        width += 260;
        
    }
    
    this.win = new Ext.Window({
        // constrain: true,
        cls: 'popup',
        closable: false,
        resizable: false,
        draggable: true,
        width: width,
        modal: true,
        frame: true,
        hideAds: true,
        layout: 'fit',
        focus: this.focusFirst,
        bodyStyle: 'padding: 15px',
        autoHeight: true,
        shadow: false,
        buttons: p.buttons,
        buttonAlign: 'center',
        keys: [p.armEnter ? {
            key: 13,
            fn: this.onSubmit,
            scope: this
        } : {}, {
            key: 27,
            fn: this.onClose,
            scope: this
        }],
        y: 50
        // renderTo: Ext.get("stage"),
    
    });
    
    this.win.show();
    // this.win.center();
    this.body = this.win.body;
    
    if (p.request) {
        this.request();
    }
    else {
        this.render(this.p);
    }
    
    if (this.p.trackAction) {
    
        J.track(this.p.trackController, this.p.trackAction, this.p.trackId);
        
    }
    
    return this;
};

J.Popup.prototype = {
    name: 'POPUP',
    
    // ========================================================================
    request: function(){
        // Temporarly render the waiting panel
        this.renderWaiting();
        var req = {
            url: this.p.request.url,
            params: this.p.request.params,
            callback: this.resp,
            scope: this
        };
        
        // call the ajax request to get the data
        Ext.Ajax.request(req);
    },
    
    // ========================================================================
    resp: function(options, success, response){
    
        var msg, title;
        
        if (success) {
            var obj = Ext.decode(response.responseText);
            if (obj.error) {
                success = false;
                msg = obj.error ? obj.error : tr('ERR__ERROR');
            }
            else {
                this.render(obj);
            }
        }
        else {
            msg = response.statusText;
        }
        
        // if an error was detected
        // if(!success) {
        // this.renderError({
        // title: title || tr('ERR__ERROR'),
        // msg: msg || response,
        // module: this
        // })
        // }
    },
    
    // ========================================================================
    renderWaiting: function(){
        if (this.panel) {
            this.panel.destroy();
        }
    },
    
    // ========================================================================
    getForm: function(obj){
    
        var fields = [];
        var lastF;
        this.firstInput = null;
        
		
		if(this.p.msg){
			fields.push({  cls: 'msg',
                html: this.p.msg
                                                                        });
		}
        
        if (obj.fields) {
        
        
            for (var i = 0, l = obj.fields.length; i < l; i++) {
                var f = obj.fields[i];
                var type = f.type;
                var v = f.v;
                if (v) {
                    f.value = eval(v);
                }
                
                if (f.width == undefined) {
                    f.width = 230;
                }
                
                if (type == 'select') {
                    var el = new Ext.form.SelectField(f);
                    fields.push(el);
                    if (!this.firstInput) {
                        this.firstInput = el;
                    }
                }
                else 
                    if (type == 'hidden') {
                        fields.push(new Ext.form.Hidden(f));
                    }
                    else 
                        if (type == 'number') {
                            var el = new Ext.form.NumberField(f);
                            fields.push(el);
                            
                            if (!this.firstInput) {
                                this.firstInput = el;
                            }
                        }
                        else 
                            if (type == 'date') {
                                var el = new Ext.form.DateField(f);
                                fields.push(el);
                                if (!this.firstInput) {
                                    this.firstInput = el;
                                }
                                
                            }
                            else 
                                if (type == 'html') {
                                    var el = new Ext.form.HtmlEditor(f);
                                    fields.push(el);
                                    if (!this.firstInput) {
                                        this.firstInput = el;
                                    }
                                    
                                }
                                else 
                                    if (type == 'text') {
                                        var el = new Ext.form.TextField(f);
                                        fields.push(el);
                                        if (f.confirmation) {
                                            f.name = f.name + 'Confirmation';
                                            f.fieldLabel = f.confirmationFieldLabel;
                                            f.confirmField = el;
                                            fields.push(new Ext.form.ConfirmTextField(f));
                                        }
                                        if (!this.firstInput) {
                                            this.firstInput = el;
                                        }
                                        
                                    }
                                    else 
                                        if (type == 'textArea' || type == 'textarea') {
                                            var el = new Ext.form.TextArea(f);
                                            fields.push(el);
                                            
                                            if (!this.firstInput) {
                                                this.firstInput = el;
                                            }
                                            
                                        }
                                        else 
                                            if (type == 'field') {
                                                var el = new Ext.form.Field(f);
                                                fields.push(el);
                                                
                                                if (!this.firstInput) {
                                                    this.firstInput = el;
                                                }
                                                
                                            }
                                            else 
                                                if (type == 'tinymce') {
                                                    this.tiny = true;
                                                    f.tinymceSettings = {
                                                        theme: "advanced",
                                                        plugins: "safari,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
                                                        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
                                                        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                                                        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|",
                                                        theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
                                                        theme_advanced_toolbar_location: "top",
                                                        theme_advanced_toolbar_align: "left",
                                                        theme_advanced_statusbar_location: "bottom",
                                                        theme_advanced_resizing: false,
                                                        extended_valid_elements: "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
                                                        template_external_list_url: "example_template_list.js"
                                                    };
                                                    
                                                    var el = new Ext.ux.TinyMCE(f);
                                                    fields.push(el);
                                                    
                                                    
                                                    if (!this.firstInput) {
                                                        this.firstInput = el;
                                                    }
                                                    
                                                }
                                                else 
                                                    if (type == 'checkbox') {
                                                        var el = new Ext.form.Checkbox(f);
                                                        fields.push(el);
                                                        
                                                        if (!this.firstInput) {
                                                            this.firstInput = el;
                                                        }
                                                        
                                                        
                                                        
                                                        
                                                    }
                                                    else 
                                                        if (type == 'upload') {
                                                            var el = new Ext.form.FileUploadField(f);
                                                            fields.push(el);
                                                            
                                                            if (!this.firstInput) {
                                                                this.firstInput = el;
                                                            }
                                                            
                                                        }
                                                        else 
                                                            if (type == 'checkboxgroup') {
                                                                f.width = 90;
                                                                var el = new Ext.form.CheckboxGroup(f);
                                                                fields.push(el);
                                                                
                                                                if (!this.firstInput) {
                                                                    this.firstInput = el;
                                                                }
                                                                
                                                            }
                                                            else 
                                                                if (type == 'radiogroup') {
                                                                    f.width = 90;
                                                                    var el = new Ext.form.RadioGroup(f);
                                                                    fields.push(el);
                                                                    
                                                                    if (!this.firstInput) {
                                                                        this.firstInput = el;
                                                                    }
                                                                    
                                                                }
                                                                else 
                                                                    if (type == 'separator') {
                                                                        fields.push({
                                                                            cls: "popup-form-separator",
                                                                            width: 550
                                                                        });
                                                                        
                                                                    }
            }
        }
        return fields;
    },
    getFormTabPanels: function(obj){
    
        var panels = [];
        
        Ext.each(obj.tabs, function(panel){
        
            panels.push({
                title: panel.title,
                layout: 'form',
                defaults: {
                    width: 230
                },
                defaultType: 'textfield',
                
                items: this.getForm({
                    fields: panel.items
                })
            })
        }, this);
        
        return panels;
    },
    // ========================================================================
    render: function(obj){
        obj = obj ||
        {};
        
        if (this.panel) {
            this.panel.destroy();
        }
        this.body = this.win.body;
        
        this.body.update('');
        
       
        
        if (this.p.tabs) {
        
            this.panel = new Ext.FormPanel({
                labelWidth: this.p.big ? 230 : 150,
                renderTo: this.body,
                title: this.p.title,
                url: this.p.submit.url,
                standardSubmit: this.p.standardSubmit,
                frame: true,
                fileUpload: this.p.fileUpload,
                autoHeight: true,
                border: false,
                items: {
                    xtype: 'tabpanel',
                    activeTab: 0,
                    deferredRender: false,
                    defaults: {
                        autoHeight: true,
                        bodyStyle: 'padding:10px'
                    },
                    items: this.getFormTabPanels(this.p)
                }
            });
            
        }
        else 
            if (this.p.right) {
            
                this.panel = new Ext.FormPanel({
                    columnWidth: 1,
                    labelWidth: this.p.big ? 240 : 170,
                    title: this.p.title,
                    renderTo: this.body,
                    url: this.p.submit.url,
                    fileUpload: this.p.fileUpload,
                    frame: true,
                    autoHeight: true,
                    standardSubmit: this.p.standardSubmit,
                    items: this.getForm(obj)
                });
                
                new Ext.Panel({
                    layout: 'column',
                    renderTo: this.body,
                    items: [this.panel, this.p.right]
                });
                
            }
            else {
            
                if (this.p.content) {
                    this.panel = new Ext.FormPanel({
                        renderTo: this.body,
                        title: this.p.title,
                        url: this.p.submit.url,
                        frame: true,
                        autoHeight: true,
                        standardSubmit: this.p.standardSubmit,
                        items: this.p.content
                    });
                    
                }
                else if(this.p.fields) {
                    this.panel = new Ext.FormPanel({
                        labelWidth: this.p.big ? 240 : 150,
                        renderTo: this.body,
                        title: this.p.title,
                        url: this.p.submit.url,
                        frame: true,
                        fileUpload: this.p.fileUpload,
                        autoHeight: true,
                        standardSubmit: this.p.standardSubmit,
                        items: this.getForm(obj)
                    });
                }
                
            }
			
		
        
        if (this.p.bottomMsg) {
            var passwordLost = this.panel.body.createChild({
                cls: 'bottomMsg',
                html: this.p.bottomMsg
            });
			
        }
		
		
		if(this.p.rememberPopup){
			
		   passwordLost.on('click', function(){
				this.closeProperly();
                new J.Popup({
                    title: "Recuperation de mot de passe",
                    requireNoLogin: true,
           			big: true,
                    msg: tr('user_popup_login_msg_withGoal'), //tr('user_popup_login_msg_withoutGoal')),
                    submit: {
                        url: '/user/lost',
						params:{
							langageId:J.languageId
						}
                    },
                    success: function(data){
                        //Message de confirmation d'envoi de mail
                    },
                    trackController: 'user',
                    trackAction: 'lostpassword',
                    scope: this,
                    fields: [{
                        type: 'text',
                        fieldLabel: tr('user_popup_login_label_email'),
                        name: 'email',
                        id: 'tmp_email'
                    }]
                });
            }, this);
			
			}
        
        
        if (this.p.rememberPopup) {
            Ext.get("global_email").replace(Ext.get('tmp_email'));
            Ext.get("global_password").replace(Ext.get('tmp_password'));
            
            this.panel.form.findField("email").el = Ext.get('global_email');
            this.panel.form.findField("password").el = Ext.get('global_password');
            if (!Ext.get('global_password').armed) {
                Ext.get('global_password').armed = true;
                Ext.get('global_password').on("keypress", function(evt){
                    if (evt.button == 12) {
                        this.onSubmit();
                    }
                }, this);
                Ext.get('remember').on("keypress", function(evt){
                    if (evt.button == 12) {
                        this.onSubmit();
                    }
                }, this);
            }
        }
        
        if (!this.p.content && this.p.fields) {
            this.firstInput.focus();
        }
        
    },
    // ========================================================================
    close: function(){
        this.win.close();
    },
    // ========================================================================
    renderError: function(p){
        p = p ||
        {};
        Ext.Msg.alert(p.title || "Errors", tr(p.msg) || "Unknown Failure");
    },
    // ========================================================================
    focusFirst: function(){
        try {
        
        } 
        catch (e) {
        
        }
    },
    
    // ========================================================================
    onClose: function(){
        this.closeProperly();
        
    },
    
    // ========================================================================
    closeProperly: function(){
        if (this.p.rememberPopup) {
            Ext.get('global_email').appendTo(Ext.get('hiddenIdentification'));
            Ext.get('global_password').appendTo(Ext.get('hiddenIdentification'));
        }
        
        if (this.p.trackAction) {
            J.track(this.p.trackController, this.p.trackAction + '-CLOSE', this.p.trackId);
        }
        this.win.close();
        this.win.destroy();
        
    },
    // ========================================================================
    onSubmit: function(){
    
        if (this.tiny && tinyMCE) {
            tinyMCE.triggerSave();
        }
        
        if (this.p.rememberPopup) {
            if (!Ext.get('global_email').getValue() || !Ext.get('global_password').getValue()) {
                return;
            }
        }
        if (this.panel && this.panel.form.isValid() && !this.submitting) {
            this.submitting = true;
            
            if (this.p.standardSubmit) {
                this.panel.form.el.dom.submit({
                    params: this.p.submit.params
                });
            }
            else {
            
                var bornDate = this.panel.getForm().findField('bornDate');
                if(!bornDate){
                	bornDate = this.panel.getForm().findField('albumReleaseDate');
                	if(!bornDate){
                		bornDate = this.panel.getForm().findField('releaseDate');
                	}
                }
                if (bornDate) {
                    var dt = Date.parseDate(bornDate.value, tr('formatDate'));
                    if (dt) {
                        var date = dt.format("Y-m-d");
                        bornDate.format = 'Y-m-d';
                        bornDate.setValue(date);
                    }
                    else {
                        Ext.MessageBox.alert('Problem', 'A problem with appear with your born date : ' + bornDate.value);
                    }
                }
                
                this.panel.form.submit({
                    params: this.p.submit.params,
                    waitMsg: tr('popup_msg_wait'),
                    waitTitle: tr('popup_msg_wait_title'),
                    clientValidation: true,
                    success: this.onSuccess,
                    failure: this.onFailure,
                    scope: this
                });
            }
            
        }
    },
    
    // ========================================================================
    onSuccess: function(form, action){
        this.submitting = false;
        if (action.result.success) {
            this.closeProperly();
            var x = action.result;
            if (this.p.trackAction) {
            
                J.track(this.p.trackController, this.p.trackAction + '-OK', this.p.trackId);
                
            }
            if (this.p.rememberPopup) {
                var hiddenIdentification = Ext.get('hiddenIdentification');
                hiddenIdentification.createChild({
                    tag: 'input',
                    type: 'text',
                    name: 'email',
                    value: Ext.get('global_email').dom.value
                });
                
                hiddenIdentification.createChild({
                    tag: 'input',
                    type: 'password',
                    name: 'password',
                    value: Ext.get('global_password').dom.value
                });
                Ext.get('formHiddenIdentification').dom.submit();
            }
            
            if (this.p.success) {
                Ext.callback(this.p.success, this.p.scope, [x]);
            }
            
            
        }
        else {
            this.renderError({
                msg: action.result.error
            });
        }
        
    },
    
    // ========================================================================
    onFailure: function(form, action){
    
        var bornDate = this.panel.getForm().findField('bornDate');
        if(!bornDate){
        	bornDate = this.panel.getForm().findField('albumReleaseDate');
        }
        if (bornDate) {
            var dt = Date.parseDate(bornDate.value, "Y-m-d");
            if (dt) {
                var date = dt.format(tr('formatDate'));
                bornDate.format = tr('formatDate');
                bornDate.setValue(date);
            }
            else {
                Ext.MessageBox.alert('Problem', 'A problem with appear with your born date in return : ' + bornDate.value);
            }
            
        }
        
        this.submitting = false;
        
        if (action.type == 'load') { // Handle the LOAD errors
            if (action.failureType == "connect") {
                Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed. Could not connect to server : '+ location.href);
            }
            else {
                if (action.response.responseText != '') {
                    var result = Ext.decode(action.response.responseText);
                    if (result ){
						if(result.errors){
							if(typeof result.errors =='string') {
                        Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed with error: ' + errors);
                  	  }
					}else if ( result.msg) {
                        Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed with error: ' + action.result.msg);
                    }
                    }else {
                        Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed with unknown error (possibly missing the "success" field in the json). Action type=' + action.type + ', failure type=' + action.failureType);
                    }
                }
                else {
                    Ext.MessageBox.alert('fs.actionfailed error', 'Form load returned an empty string instead of json');
                }
            }
        }
        
        if (action.type == 'submit') { // Handle the SUBMIT errors
            if (action.failureType == "connect") {
				var sData = "";
                sData = Ext.util.JSON.decode(action.response.responseText);
                if(sData){
					var aErrorList = sData.errors.split(" ");
				}else{
					var aErrorList = {"message" : "Error to contact Server"};
				}
				
                switch (aErrorList[0]) {
                    case "Duplicate":
                        Ext.MessageBox.alert('Error : Param already used', 'This parameters is already used : ' + aErrorList[2] + ", please change this param.");
                        break;
                    default:
                        Ext.MessageBox.alert('fs.actionfailed error', 'Form submit failed. Could not connect to server : '+ location.href);
                        break;
                }
            }
            else 
                if (action.failureType == "server") {
                
                // These arent "errors" as such, they are validation issues trapped by the server script and passed back for the user to correct
                }
                else {
                    var result = Ext.decode(action.response.responseText);
                    if (result && result.msg) {
                        Ext.MessageBox.alert('fs.actionfailed error', 'Form submit failed with error: ' + action.result.msg);
                    }
                    else {
                        var parseResult = action.response.responseText.split(" ");
                        switch (parseResult[0]) {
                            case "Duplicate":
                                Ext.MessageBox.alert('Error : Param already used', 'This parameters is already used : ' + parseResult[2] + ", please change this param.");
                                break;
                            default:
                                Ext.MessageBox.alert('actionfailed Error', 'Form submit returned unknown error. Action type=' + action.type + ', failure type=' + action.failureType);
                                break;
                                
                        }
                    }
                }
        }
        
        if (this.p.trackAction) {
        
            J.track(this.p.trackController, this.p.trackAction + '-ERR', this.p.trackId);
            
        }
        // Ext.MessageBox.alert(tr('ERR__ERROR'), action.response.statusText);
    }
};
/**
 * @author Steed
 */

J.Seo = function() {

	return {
		account : 'Jiwa',
		title : '',
		url : '',
		host : 'http://'+location.hostname,
		link_clear : function(string) {
				
			string = string.replace(/\W/g, "-");
			string = string.replace(/\-\-+/g, "-");
			return string;
			
		},
		link_href : function(data) {

			if (data.songName && data.trackId) {

				this.trackId= data.trackId;
				string = this.link_clear(data.artistName + '-' + data.artistId) + '/'
						+ this.link_clear(data.albumName + '-' + data.albumId) + '/'
						+ this.link_clear(data.songName+'-' + data.trackId )+ '.html';

			} else if (data.albumName && data.albumId) {
			
				string = this.link_clear(data.artistName + '-' + data.artistId) + '/'
						+ this.link_clear(data.albumName + '-' + data.albumId) + '.html';
			} else if (data.artistName && data.artistId) {
				string = this.link_clear(data.artistName + '-' + data.artistId) + '.html';
			}  else if (data.playlistName && data.playlistId) {
				string = this.link_clear(data.playlistName + '-' + data.playlistId) + '.html';
			}else if (data.userName && data.userId) {
				string = this.link_clear(data.userName + '-' + data.userId) + '.html';
			} else if (data.radioName && data.radioId) {
				string = this.link_clear(data.radioName + '-' + data.radioId) + '.html';
			} else if (data.title && data.newsId) {
				string = this.link_clear(data.title + '-' + data.newsId) + '.html';
			} else {

				string = '';
			}
			
			

			return string;
		},
		

		init : function(data,type){
			
			this.type = type;
			switch (type) {

				case 'artist' : {
					
					this.id = data.artistId;

					this.title = data.artistName ;
					this.url = J.Seo.host + '/'
							+ this.link_href(data);
					if (T.languageId) {
						this.msg = "Viens voir cet artiste sur JIWA :";
					}else{
						this.msg = "Come see this artist on JIWA : ";
					}

				}
					break;

				case 'album' : {
					
					this.id = data.albumId;

					this.title = data.albumName + ' - ' + data.artistName ;
					this.url = J.Seo.host+ '/album/'
							+ this.link_href(data);
					if (T.languageId) {
						this.msg ="Viens écouter cet album sur JIWA : ";
					}else{
						this.msg = "Come listen this album on JIWA :";
					}
				}
					break;
					

				case 'track' : {
					
					this.id = data.trackId;
		

					this.title = data.songName + ' - ' + data.albumName + ' - ' + data.artistName;
					this.url = J.Seo.host+ '/track/'
							+ this.link_href(data);
					
					if (T.languageId) {
						this.msg = "Viens écouter ce morceau sur JIWA : ";
					}else{
						this.msg = "Come listen this track on JIWA :";
					}

				}
					break;

				case 'user' : {

					this.title = data.userName ;
					this.url = J.Seo.host + '/user/'
							+ this.link_href(data);
					
					if (T.languageId) {
						this.msg = "Viens découvrir ce profil sur JIWA :";
					}else{
						this.msg = "Come listen this profil on JIWA : ";
					}

				}
					break;

				case 'playlist' : {
					
					this.id = data.playlistId;
					this.title = data.playlistName ;
					this.url = J.Seo.host + '/playlist/'
							+ this.link_href(data);
					
					if (T.languageId) {
						this.msg = "Viens écouter cette playlist sur JIWA :";
					}else{
						this.msg = "Come listen this playlist on JIWA :";
					}

				}
					break;
					
				case 'radio' : {
					
					this.title = 'Jiwa Radio';
					this.url = J.Seo.host+ '/radio.html';
					if (T.languageId) {
						this.msg = "Viens découvrir les JIWA Radios :";
					}else{
						this.msg = "Come listen the JIWA radios :";
					}
				}
					break;

				case 'station' : {
					
					this.title = 'Jiwa Radio';
					this.url = J.Seo.host + '/radio/'
							+ this.link_href(data);
					if (T.languageId) {
						this.msg = "Viens découvrir la JIWA Radios :"+data.radioName;
					}else{
						this.msg = "Come listen the JIWA radio :"+data.radioName;
					}
				}
					break;
					
					
				case 'news' : {
					
					this.title = 'Jiwa News';
					this.url = J.Seo.host + '/news/'
							+ this.link_href(data);
					if (T.languageId) {
						this.msg = "Viens lire cet article :"+data.title;
					}else{
						this.msg = "Come read this news :"+data.title;
					}
				}
					break;

			}

	
	 
	if(data.permalink){
					
					this.url = J.Seo.host + '/'+data.permalink;
					
				}
			
	
		

		document.getElementById('wildfire_msg').value = this.msg +' <a href="'+J.Seo.url+'">'+J.Seo.url+'</a>';
				
				
				return this;		

		},
		copy : function() {
			
			
			J.track('copy', 'url',J.Seo.type);
			J.copy(J.Seo.url,tr('url_copied')+" : " + J.Seo.url);
		},
		
		mail : function() {
			
	
				J.track('seo','mailto',J.Seo.type);
				WildfireBtn.onClick({module : 'share',
				partner :'308341'},'wildfire_msg');
						
	
		},
		favourite : function() {

			var addthis_url = J.Seo.url;
			var addthis_title = J.Seo.title+ ' - Jiwa ';

			if (document.all) {
				window.external.AddFavorite(addthis_url, addthis_title);
			} else {
				window.sidebar.addPanel(addthis_title, addthis_url, "");
			}

		},
		blog :function(){
		
	
		J.track('seo','blog',J.Seo.type);
		
			if(J.Seo.type =='track'){
						
					J.WizardSong.show({trackId:J.Seo.trackId, permalink : J.Seo.data.artistNameLink, name:J.Seo.data.artistName});
					
			}else {
				
			
			J.WizardPlaylist.show({ domain : J.Seo.type , id : J.Seo.id, expert : false, permalink : J.Seo.url, name:J.Seo.title});
					
		}
		

						
		},
		widget_code :function(track){
			
			if(track){
				J.track('widget','code',J.Seo.type);
			}
			
			
			if (J.Seo.type == 'track') {
			
				return '<div style="position: relative; width: 315px; height: 40px; overflow: hidden;">'+
					'<a style="position: absolute; left:25px;" href="'+J.Seo.url+'">'+J.Seo.title.replace(/'/g, "")+'</a>'+
					'<div style="position: absolute;">'+
					'<object width="315" height="40" id="music-widget">'+
					'<param name="wmode" value="transparent" />'+
					'<param name="type" value="application/x-shockwave-flash" />'+
					'<param name="allowScriptAccess" value="always" />'+
					'<param name="movie" value="http://'+location.hostname+'/res/widget/monotitle.swf?trackId='+J.Seo.id+'&skin=round" />'+
					'<embed src="http://'+location.hostname+'/res/widget/monotitle.swf?trackId='+J.Seo.id+'&skin=round" wmode="transparent" type="application/x-shockwave-flash" name="music-widget" width="315" height="40" allowScriptAccess="always">'+
					'</embed>'+
					'</object>'+
					'</div></div>'+
					'<img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bT*xJmx*PTEyMjAzMjU4OTgxNDQmcHQ9MTIyMDMyNTg5OTk1NiZwPTMwODM*MSZkPSZuPSZnPTE=.gif" />';
				
			}
			else {
				
				
					return '<div style="position: relative; width: 160px; height: 245px; overflow: hidden;">'+
					'<a style="position: absolute; left:25px;" href="'+J.Seo.url+'">'+J.Seo.title.replace(/'/g, "")+'</a>'+
					'<div style="position: absolute;">'+
					'<object width="160" height="245" id="music-widget">'+
					'<param name="wmode" value="transparent" />'+
					'<param name="type" value="application/x-shockwave-flash" />'+
					'<param name="allowScriptAccess" value="always" />'+
					'<param name="movie" value="http://'+location.hostname+'/res/widget/compact.swf?'+J.Seo.type+'Id='+J.Seo.id+'&skin=bright" />'+
					'<embed src="http://'+location.hostname+'/res/widget/compact.swf?'+J.Seo.type+'Id='+J.Seo.id+'&skin=bright" wmode="transparent" type="application/x-shockwave-flash" name="music-widget" width="160" height="245" allowScriptAccess="always">'+
					'</embed>'+
					'</object>'+
					'</div>'+
					'</div>'+
					'<img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bT*xJmx*PTEyMjAzMjUxNDIyNjImcHQ9MTIyMDMyNTE*NTU3MyZwPTMwODM*MSZkPSZuPSZnPTE=.gif" />';
					
				}
				
						
		},
		share: function(){

	

		J.track('seo','bookmarks',J.Seo.type);
		
		WildfireBtn.addParam('bookmarkURL');
			WildfireBtn.onClick({
				module: 'bookmarks',
				partner: '308341',
				bookmarkURL :	J.Seo.url	
			}, 'wildfire_msg');
		}

	};
}();


J.View.JGrid = Ext.extend(Ext.grid.GridPanel, {

	remoteSort:false,
	displayMsg: tr('trackGrid_toolbar_msg'),
    emptyMsg: tr('trackGrid_toolbar_empty'),
	menu :[],
    /**
     *
     * @param {Object} p
     * - expandActions array of arrays
     */
    constructor: function(p) {
	
		this.selectionModel = new Ext.grid.CheckboxSelectionModel({singleSelect:false,
       // private
   	handleMouseDown : function(g, rowIndex, e){
		 if(e.button !== 0 || this.isLocked()){
            return;
        };
        var view = this.grid.getView();
        if(e.shiftKey && this.last !== false){
			e.stopEvent();
            var last = this.last;
            this.selectRange(last, rowIndex, e.ctrlKey);
            this.last = last; // reset the last
            view.focusRow(rowIndex);
			
        }else{
            var isSelected = this.isSelected(rowIndex);
		   e.stopEvent();
            var row = e.getTarget('.x-grid3-row-checker');
            if (!row) {
				if (e.ctrlKey && isSelected) {
					this.deselectRow(rowIndex);
				}
				else 
					if (!isSelected || this.getCount() > 1) {
						this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);
						view.focusRow(rowIndex);
					}
			}
        }
 
    }
		});
        this.selectionModel.expand = false;
		this.selectionModel.width =30;
		
		p.columns.defaultSortable = true;
        p.columns.push(this.selectionModel);
        

		
        var totalWidth = p.width||682;
        var totalColWidth = 0;
		
		var minWidth = 0;
		var nbLeftColum = 0;
		Ext.each(p.columns, function(column) {
			if (column.width) {
                minWidth += column.width;
			}else{
				nbLeftColum +=1;	
			}
		});
		
		totalLeftWidth = totalWidth - minWidth ;

        Ext.each(p.columns, function(column) {
           
            // First pass
            if (!column.width && column.colWidth) {
                column.width = totalLeftWidth * column.colWidth / nbLeftColum;
            }
        }, this);
        
        
    
		
        // Toolbars
		this.tbar = new Ext.ActionPagingToolbar({
            store: p.store,
			pageSize:25,  
			grid:this,
            displayInfo: true,
            displayMsg: this.displayMsg,
            emptyMsg: this.emptyMsg
        });
		
		this.bbar = new Ext.ActionPagingToolbar({
            store: p.store,
			pageSize:25,  
			grid:this,
            displayInfo: true,
            displayMsg: this.displayMsg,
            emptyMsg: this.emptyMsg
        });
			
		
		J.fc.tbar = this.tbar;
		J.fc.grid =this;
		
        var baseP = {
            stripeRows: true,
            columns: p.columns,
			store: p.store,
            sm: this.selectionModel,
            cls: "jGrid",
			width:totalWidth,
            autoHeight: true,
			enableDragDrop :true,
			enableDrag :true,
			ads:true,
			enableColumnHide: false,
        	enableColumnMove: false,
            frame: false,
			loadingText : tr('content_loading'),
			loadMask: true,
            border: true,
            iconCls: 'icon-grid',
            tbar: this.tbar,
			bbar: this.bbar
        };
		
	
		
		baseP.listeners = {
				render: function(g){
					var ddrow = new Ext.ux.dd.GridReorderDropTarget(g, {
						copy: true,
						listeners: {
							afterrowmove: function(objThis, oldIndex, newIndex, records){
							
								g.movefromPlaylist(records,newIndex);
								
							}
						}
					});
					
				}
			}

		baseP.viewConfig = {
				ads:true
			};
		

	
		if (p.showText) {
		
			baseP.viewConfig = {
				enableRowBody: true,
				showPreview: true,
				
			ads:true,
				getRowClass: function(record, rowIndex, x, store){
					if (record.data.text && record.data.text != null) {
						x.body = '<p style="font-style: italic;margin-left:80px; margin-bottom: 10px; color: #444444">' +
						'<a href="#user/'+record.data.userId+'">'+record.data.userName + '</a> : '+record.data.text +
						'</p>';
					}
					else {
						x.body = '<p style="font-style: italic;margin-left:80px; margin-bottom: 10px; color: #444444">' +
						'<a href="#user/'+record.data.userId+'">'+record.data.userName + '</a>' +
						'</p>';
					}
					
					return 'x-grid3-row-expanded';
				}
			}
			
		}

        for (var i in p) {
            baseP[i] = p[i];
        }
        baseP.cls = "jGrid " + baseP.cls;
        J.View.JGrid.superclass.constructor.call(this, baseP);

        this.addEvents({
			scope:this,
            jCellClick: true
        });
		xxxx = this;
		
		if(!p.noLoad){
			
			
			p.store.load();
		}
    },

    onClick: function(e, t){
        
        var row, rowExpanded, rowSelected, record, fieldName;
        if ((row = e.getTarget('.x-grid3-cell'))) {
			e.stopEvent();
            fieldName = row.className;
            var x = /x-grid3-td-([^ ]*)/.exec(fieldName);
            if (!x) {
                console.warn("not a col", fieldName, row);
                return;
            }
            fieldName = x[1];
			
			

            row = Ext.get(t).findParent(".x-grid3-row");
            if (!row) {
                
				 this.processEvent("click", e);
                return;
            }
			
			   rowSelected = this.selectionModel.isSelected(row.rowIndex);
  
            record = this.getStore().getAt(row.rowIndex);
            
        
							
			
			switch (fieldName) {
						case "songName":
					if (record.data.trackId) {
						J.fc.gotoUrl("track", record.data.trackId);
					}
					break;
				case "artistId":
				case "artistName":
					if (record.data.artistId) {
						J.fc.gotoUrl("artist", record.data.artistId);
					}
					break;
					case "albumId":
				case "albumName":
					if (record.data.albumId) {
						J.fc.gotoUrl("album", record.data.albumId);
					}
					break;
				case "userId":
				case "userName":
					if (record.data.userId) {
						J.fc.gotoUrl("user", record.data.userId);
					}
					break;
					
					case "playlistId":
				case "playlistName":
					if (record.data.playlistId) {
						J.fc.gotoUrl("playlist", record.data.playlistId);
					}
					break;
					
			case "newsId":
				case "title":
					if (record.data.newsId) {
						J.fc.gotoUrl("news", record.data.newsId);
					}
					break;				
								
							}
							
							   
							
						}
			
	
        this.fireEvent("jCellClick", this, record, fieldName, rowSelected,t.className);
    },
	   onCellClick: function(grid, record, fieldName, rowSelected,cls) {
        switch (fieldName) {
			case "addToNewPlaylist":
					if (!J.me.isLoggedIn()) {
						J.me.controller.requireLogin();
					}
					else {
						this.addToNewPlaylist(rowSelected, record);
					}
			break;
			case "play":
			case "enqueue":	
						this.addToPlayer(rowSelected,record,fieldName == "play");
			break;
						
			case "addToPlaylist":
				if (!J.me.isLoggedIn()) {
					J.me.controller.requireLogin();
				}
				else {
					this.addToPlaylist(rowSelected, record);
				}
			break;
			
			case "actions": 
				switch (cls) {
					case "icon play":
					case "icon enqueue":	
						this.addToPlayer(rowSelected,record,cls == "icon play");
					break;
						
					case "icon add":
				if (!J.me.isLoggedIn()) {
					J.me.controller.requireLogin();
				}
				else {
					this.addToPlaylist(rowSelected, record);
				}
					break;
				}
			break;
			
			case "suggest":
					if (!J.me.isLoggedIn()) {
						J.me.controller.requireLogin();
					}
					else {
						J.fc.getController("track", true).suggest(record.data);
					}
			break;
			
			case "delete":
				if (!J.me.isLoggedIn()) {
					J.me.controller.requireLogin();
				}
				else {
					this.removefromPlaylist(rowSelected, record);
				}
			break;
			
			case "download":
				if (record.data.starzikTrackUrl) {
                    J.track('starzik', 'download','track');
                    window.open( record.data.starzikTrackUrl, "Jiwa Download - starzik", "");   
				}else if (record.data.itunesTrackUrl) {
                    J.track('itunes', 'download','track');
                    window.open('http://clk.tradedoubler.com/click?p=23753&partnerId=2003&a=1570290&g=0&td_partnerId=2003&url=' + record.data.itunesTrackUrl, "Jiwa Download - Itunes", "");   
				}else{
					J.InfoBox.msg("Ce morceau n'est pas encore disponible en téléchargement");
				}
				break;
			
			default:
				//console.warn("Mousedown on ", fieldName);
				return true;
			break;	
			
		}
    },
	onPlayAll: function() {
			var tracks =[];
		
		this.store.data.each(function(item,record,a){
			
			tracks.push(item.data);
		});
		J.fc.getController("player", true).jwAddTracks(tracks, {
							play: true
						});
    },
    onAddAll: function(e, t) {

		J.fc.getController("playlistAdder", true).addAlltracksOfGrid(this);
		
    },
    onEnqueueAll: function() {
		var tracks =[];
		
		this.store.data.each(function(item,record,a){
			tracks.push(item.data);
		});
		
       J.fc.getController("player", true).jwAddTracks(tracks, {
							play: false
						});
    },
	addToNewPlaylist:function(rowSelected,record){
							
			var selectedRecords = [];
						
			// Check if clicked record is already selected.				
			if (rowSelected) {
				selectedRecords = this.selectionModel.getSelections();
			}else {
			// Clear selected.
			this.selectionModel.clearSelections();
			selectedRecords = [record];
			}
			
			J.fc.getController("playlistAdder", true).create({
					records: selectedRecords
			});
		
	},
	
	removeMySuggestion:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.data.id,
				trackId: record.data.trackId,
				controller: controller,
				methode: "delMySuggestions"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	
	removeOtherSuggestions:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.data.id,
				trackId: record.data.trackId,
				controller: controller,
				methode: "delOtherSuggestions"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
		
	},
	
	removeTranslation:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				translationLabelId: record.data.translationLabelId,
				languageId : record.data.languageId,
				controller: controller,
				methode: "delTranslation"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
		
	},
							
	removefromPlaylist:function(rowSelected,record){
		var selectedRecords = [];
		// Check if clicked record is already selected.				
		if (rowSelected) {
			selectedRecords = this.selectionModel.getSelections();
		}else {
		// Clear selected.
			this.selectionModel.clearSelections();
			selectedRecords = [record];
		}
		
		if(this.store.baseParams.playlistId){
			
			var start =  J.fc.tbar.pageSize*(J.fc.tbar.page-1);
			J.fc.getController("playlistAdder", true).removeTracks(selectedRecords,this.store.baseParams.playlistId,this.store,start,J.fc.tbar.pageSize);
		}
		
		
	},
	movefromPlaylist:function(selectedRecords,newIndex){
		
		
		if(this.store.baseParams.playlistId){
			var start =  J.fc.tbar.pageSize*(J.fc.tbar.page-1);
			var position = newIndex +start;
			J.fc.getController("playlistAdder", true).moveTracks(selectedRecords,this.store.baseParams.playlistId,this.store,position,start,J.fc.tbar.pageSize);
		}
		
		
	},
	addToPlaylist:function(rowSelected,record){
							
			var selectedRecords = [];
						
			// Check if clicked record is already selected.				
			if (rowSelected) {
							selectedRecords = this.selectionModel.getSelections();
			}else {
				// Clear selected.
				this.selectionModel.clearSelections();
				selectedRecords = [record];
			}
			
			
			
			J.fc.getController("playlistAdder", true).show({
							records: selectedRecords
						});
		
	},
	addToPlayer:function(rowSelected,record,play){
							
						var selectedRecords = [];
						
						// Check if clicked record is already selected.				
						if (rowSelected) {
							selectedRecords = this.selectionModel.getSelections();
						}
						else {
							// Clear selected.
							this.selectionModel.clearSelections();
							selectedRecords = [record];
						}
						var tracks = [];
						Ext.each(selectedRecords, function(rec){
							tracks.push(rec.data);
						});
						J.fc.getController("player", true).jwAddTracks(tracks, {
							play: play
						});
		
	},
	/***************************************************************
	 * ACTION MENU OPTION
	 **************************************************************/
	removeItem:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqDelete"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
		
	}
});
J.View.JList = Ext.extend(Ext.grid.GridPanel, {
    /**
     *
     * @param {Object} p
     * - expandActions array of arrays
     */
    constructor: function(p) {
        this.selectionModel = new Ext.grid.CheckboxSelectionModel({ singleSelect:false});
        this.selectionModel.expand = true;
		this.selectionModel.width =30;
        p.columns.push(this.selectionModel);
        
        this.fieldsExpanders = {};
        this.fieldsClickableAfterExpand = {};
        
       var totalWidth = p.width ||682 ;
        var totalColWidth = 0;
		
		var minWidth = 0;
		var nbLeftColum = 0;
		Ext.each(p.columns, function(column) {
			if (column.width) {
                minWidth += column.width;
			}else{
				nbLeftColum +=1;	
			}
		});
		
		totalLeftWidth = totalWidth - minWidth;

        Ext.each(p.columns, function(column) {
          
            // First pass
            if (!column.width && column.colWidth) {
                column.width = totalLeftWidth * column.colWidth / nbLeftColum;
            }
        }, this);
        
        
		
        
        // define a template to use for the detail view
        //p.illustrationUrl = J.MEDIAPATH + '/album/100/{albumId}.jpg';
     
        
        // Toolbars
        
         this.bbar = new Ext.ActionPagingToolbar({
            store: p.store,
			pageSize:25,  
			grid:this,
            displayInfo: true,
            displayMsg: tr('trackGrid_toolbar_msg'),
            emptyMsg: tr('trackGrid_toolbar_empty')
        });
      
		
			this.tbar = new Ext.ActionPagingToolbar({
            store: p.store,
			pageSize:25,  
			grid:this,
            displayInfo: true,
            displayMsg: tr('trackGrid_toolbar_msg'),
            emptyMsg: tr('trackGrid_toolbar_empty')
        });

        var baseP = {
            stripeRows: true,
            columns: p.columns,
			loadingText : tr('content_loading'),
			loadMask: true,
			store: p.store,
            sm: this.selectionModel,
            cls: "jGrid",
			width : totalWidth,
			enableColumnHide: false,
        	enableColumnMove: false,			 			
            autoHeight: true,
            frame: false,
            border: true,
            iconCls: 'icon-grid',
            tbar: this.tbar,
			bbar: this.bbar
        };   
		
		baseP.viewConfig = {
			ads:true
			};

        for (var i in p) {
            baseP[i] = p[i];
        }
        baseP.cls = "jList " + baseP.cls;
        J.View.JList.superclass.constructor.call(this, baseP);
        this.addEvents({
            jCellClick: true
        });
		xxxx = this;
		
		if(!p.noLoad){
			p.store.load();
		}
		
		J.fc.jList =this;
    },
	onPlayAll: function() {
			var tracks =[];
		
		this.store.data.each(function(item,record,a){
			
			tracks.push(item.data);
		});
		J.fc.getController("player", true).jwAddTracks(tracks, {
							play: true
						});
    },
    onAddAll: function(e, t) {
	
		var tracks =[];
		
		this.store.data.each(function(item,record,a){
			
			tracks.push(item);
		});
        J.fc.getController("playlistAdder", true).show({
							records: tracks
						});
		
    },
    onEnqueueAll: function() {
		var tracks =[];
		
		this.store.data.each(function(item,record,a){
			tracks.push(item.data);
		});
		
       J.fc.getController("player", true).jwAddTracks(tracks, {
							play: false
						});
    },
    onMouseDown: function(e, t) {
        var row, rowExpanded, rowSelected, record, fieldName;
        if ((row = e.getTarget('.x-grid3-cell'))) {
			fieldName = row.className;
			var x = /x-grid3-td-([^ ]*)/.exec(fieldName);
			if (!x) {
				console.warn("not a col", fieldName, row);
				return;
			}
			fieldName = x[1];
			
			//row = e.getTarget('.x-grid3-row');
			row = Ext.get(t).findParent(".x-grid3-row");
			if (!row) {
				console.warn("no rows were selected");
				return;
			}
			
			record = this.getStore().getAt(row.rowIndex);
			
			switch (fieldName) {
				case "songName":
					if (record.data.trackId) {
						J.fc.gotoUrl("track", record.data.trackId);
					}
					break;
				case "artistId":
				case "artistName":
					if (record.data.artistId) {
						J.fc.gotoUrl("artist", record.data.artistId);
					}
					break;
					case "albumId":
				case "albumName":
					if (record.data.albumId) {
						J.fc.gotoUrl("album", record.data.albumId);
					}
					break;
				case "userId":
				case "userName":
					if (record.data.userId) {
						J.fc.gotoUrl("user", record.data.userId);
					}
					break;
					
					case "playlistId":
				case "playlistName":
					if (record.data.playlistId) {
						J.fc.gotoUrl("playlist", record.data.playlistId);
					}
					break;
					
				case "newsId":
				case "title":
					if (record.data.newsId) {
						J.fc.gotoUrl("news", record.data.newsId);
					}
					break;	
					
			}
			
		}
				
        this.fireEvent("jCellClick", this, record, fieldName, rowSelected);
    },
	/***************************************************************
	 * ACTION MENU OPTION
	 **************************************************************/
	removeItem:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqDelete"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
		
	},
	subscribe:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqSubscribe"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	unSubscribe:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqUnSubscribe"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	hide:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqHide"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	show:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqShow"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	restrict:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqRestrict"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	},
	allow:function(controller){
		Ext.Msg.wait(tr('popup_msg_wait'));
		selectedRecords = this.selectionModel.getSelections();
		var nbrPlaylist = selectedRecords.length;
		J.fc.multipleRequest = [];
		Ext.each(selectedRecords, function(record) {
			var elem = {
				id: record.id,
				controller: controller,
				methode: "reqAllow"
			};
			J.fc.multipleRequest.push(elem);
		}, this);
		J.fc.execNextRequest();
	}
});

        	
Ext.ActionPagingToolbar = Ext.extend(Ext.PagingToolbar, {
	
	autoCreate: {
        cls:'x-toolbar x-small-editor jwPaging',
        html:'<table cellspacing="0"><tr></tr></table>'
    },
	ActionPaging:true,
	
    /**
     * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the paging toolbar should use as its data source (required).
     */
    /**
     * @cfg {Boolean} displayInfo
     * True to display the displayMsg (defaults to false)
     */
    /**
     * @cfg {Number} pageSize
     * The number of records to display per page (defaults to 20)
     */
    pageSize: 25,
	adjacents:2,
	page:3,
    /**
     * @cfg {String} displayMsg
     * The paging status message to display (defaults to "Displaying {0} - {1} of {2}").  Note that this string is
     * formatted using the braced numbers 0-2 as tokens that are replaced by the values for start, end and total
     * respectively. These tokens should be preserved when overriding this string if showing those values is desired.
     */
    displayMsg : ' Items : <b>{0}</b> à <b>{1}</b> sur <b>{2}</b>',
    /**
     * @cfg {String} emptyMsg
     * The message to display when no records are found (defaults to "No data to display")
     */
    emptyMsg : 'No data to display',
    /**
     * Customizable piece of the default paging text (defaults to "Page")
     * @type String
     */
    beforePageText : "Page",

    // private
    onRender : function(ct, position){

		this.position =position;
		this.ct=ct;
        Ext.PagingToolbar.superclass.onRender.call(this, ct, position);
		

    },

	   // private
    onLoad : function(store, r, o){
        if(!this.rendered){
            this.dsLoaded = [store, r, o];
            return;
        }
		
		
       this.cursor = o.params ? o.params[this.paramNames.start] : 0;
       var d = this.getPageData(), ap = d.activePage, ps = d.pages;

        this.page = ap;
		this.lastpage = ps;
		this.updatePagination();
        this.first.setDisabled(ap == 1);
        this.prev.setDisabled(ap == 1);
        this.next.setDisabled(ap == ps);		
        this.last.setDisabled(ap == ps);
        this.updateInfo();		
        this.fireEvent('change', this, d);
    },

   // private
    getPageData : function(){
        var total = this.store.getTotalCount();
		
		var count = this.store.getCount();
		this.pageSize = this.pageSize<count ? count :this.pageSize;
        return {
            total : total,
            activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
            pages :  total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
        };
    },
	createPageButton :function(counter){
		
		if (counter == this.page) {
			this.addButton({
            tooltip: "page "+counter,
			text:counter,
            disabled: true,
            handler: this.onClick.createDelegate(this, [counter])
        });
			
		}
		else {
			this.addButton({
	            tooltip: "page "+counter,
				text:counter,
	            disabled: false,
	            handler: this.onClick.createDelegate(this,[counter])
	        });
			
		}
		
	},
	
	 onLoadError : function(){
	 	
		Ext.Msg.alert('error','Error during Loading');
	
	 },
	 
	 

	updatePagination:function(){
		
		if (this.roundedBox) {
            var tdLeft = Ext.get(this.addDom({}).el.parentNode);
            tdLeft.addClass("bg-left");
            tdLeft.update("&#160;");
        }
		
			this.el.remove();
		this.el = this.ct.createChild(Ext.apply({ id: this.id },this.autoCreate), this.position);
        this.tr = this.el.child("tr", true);
		if(this.displayInfo){
            this.displayEl = Ext.fly(this.el.dom).createChild({cls:'x-paging-info'});
        }
		
        this.add('<span style="margin-left:5px">'+this.beforePageText+' : </span>');
		this.first = this.addButton({
            tooltip: this.firstText,
            iconCls: "x-tbar-page-first",
            disabled: true,
            handler: this.onClick.createDelegate(this, ["first"])
        });
        this.prev = this.addButton({
            tooltip: this.prevText,
            iconCls: "x-tbar-page-prev",
            disabled: true,
            handler: this.onClick.createDelegate(this, ["prev"])
        });
        this.addSeparator();
				
        
		if(this.lastpage >= 1){
						
						if (this.lastpage < 7 + (this.adjacents * 2)){//not enough pages to bother breaking it up
								for (counter = 1; counter <= this.lastpage; counter++){
									this.createPageButton(counter);
									}
							}
						else if(this.lastpage > 5 + (this.adjacents * 2)){
								//close to beginning; only hide later pages
								if(this.page < 1 + (this.adjacents * 2)){
									
										for (counter = 1; counter < 4 + (this.adjacents * 2); counter++){
												this.createPageButton(counter);
											}
											
										var lpm1 = (this.lastpage-1);
										
										this.addText('. . .');
										this.createPageButton(lpm1);
										this.createPageButton(this.lastpage);
											
								}else if(this.lastpage - (this.adjacents * 2) > this.page && this.page > (this.adjacents * 2)){
										
										this.createPageButton(1);
										this.createPageButton(2);
										this.addText('. . .');
										
										for (counter = this.page - this.adjacents; counter <= this.page + this.adjacents; counter++){
											this.createPageButton(counter);
										}
												
										var lpm1 = (this.lastpage-1);
										
										this.addText('. . .');
										this.createPageButton(lpm1);
										this.createPageButton(this.lastpage);
								}else{
										this.createPageButton(1);
										this.createPageButton(2);												
										this.addText('. . .');
												
										for (counter = this.lastpage - (2 + (this.adjacents * 2)); counter <= this.lastpage; counter++)
												this.createPageButton(counter);
										}
							}
					
		}
		
		this.addSeparator();
        this.next = this.addButton({
            tooltip: this.nextText,
            iconCls: "x-tbar-page-next",
            disabled: true,
            handler: this.onClick.createDelegate(this, ["next"])
        });
        this.last = this.addButton({
            tooltip: this.lastText,
            iconCls: "x-tbar-page-last",
            disabled: true,
            handler: this.onClick.createDelegate(this, ["last"])
        });
		
		
		this.addFill();
		
		td = Ext.get(this.nextBlock());
		td.addClass('x-paging-info-container');
		this.displayEl = td.createChild({cls:'x-paging-info'});
		
		//Sous menu des grids
		if (this.ActionPaging) {
			if (J.fc.controller.mine() && this.grid.optionsActionMenu.admin.length > 0) {
				var menu = this.grid.optionsActionMenu.admin;
			}else{
				var menu = this.grid.optionsActionMenu.normal;
			}
			
			var x=this.store;
			if (menu.length > 0) {
				this.addButton({
					cls: "jwPaging-actions",
					text: "Actions",
					menu: menu,
					listeners:{
						click:function(){
							J.fc.store = x;
						},
						scope: this
					}
				},this);
			}
			   	
		}
		
		//td = Ext.get(this.nextBlock());
		//td.addClass('border-right-pagination');
	    


	},



    // private
    onClick : function(which){
        var store = this.store;
	
		this.store.removeAll();
        switch(which){
            case "first":
                this.doLoad(0);
            break;
            case "prev":
                this.doLoad(Math.max(0, this.cursor-this.pageSize));
            break;
            case "next":
                this.doLoad(this.cursor+this.pageSize);
            break;
            case "last":
                var total = store.getTotalCount();
                var extra = total % this.pageSize;
                var lastStart = extra ? (total - extra) : total-this.pageSize;
                this.doLoad(lastStart);
            break;
            case "refresh":
                this.doLoad(this.cursor);
            break;
			default:
			
				if(this.which != which){
					this.changePage(which);
				}
				
				this.which =which;
				
			break;
        }
		
		
		
    }
});

J.InfoBox = function() {
	return {
		msg: function(text, showDuration) {
			if (showDuration === undefined) {
				showDuration = 2;
			}
			
			
			this.msgCt = new Ext.Window({
					title: '',
					bodyStyle: "padding: 8px; background-color: white; padding-bottom: 16px",
					style: "width: 500px;",
					html: text,
					renderTo: document.body,
					shadow: false,
					closable: true,
					movable: false
				});
		
			
 			this.msgCt.alignTo(J.fc.body, 'b-b');
			this.msgCt.show();
			this.msgCt.el.pause(showDuration).ghost("t", {
				callback: function(){
					if (this.msgCt) {
						this.msgCt.destroy();
					}
				}
			},this);
			//msgCt.el.slideIn('b').pause(2).ghost("b", {remove : true});
		},
		
		init: function() {
			var lb = Ext.get('lib-bar');
			if (lb) {
				lb.show();
			}
		}
	};
}();
/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
	    /**
     * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
     */
    listClass: '',
    /**
     * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
     */
    selectedClass: 'x-combo-selected',
    /**
     * @cfg {String} listAlign A valid anchor position value. See {@link Ext.Element#alignTo} for details on supported
     * anchor positions (defaults to 'tl-bl')
     */
    listAlign: 'tl-bl',
    /**
     * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
     */
    maxHeight: 200,
    /**
     * @cfg {Number} minHeight The minimum height in pixels of the dropdown list when the list is constrained by its
     * distance to the viewport edges (defaults to 90)
     */
    minHeight: 90,
    /**
     * @cfg {String} triggerAction The action to execute when the trigger field is activated.  Use 'all' to run the
     * query specified by the allQuery config option (defaults to 'query')
     */
    triggerAction: 'query',
    /**
     * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
     * (defaults to 4 if remote or 0 if local, does not apply if editable = false)
     */
    minChars : 4,
    /**
     * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
     * delay ({@link #typeAheadDelay}) if it matches a known value (defaults to false)
     */
    typeAhead: false,
    /**
     * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
     * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
     */
    queryDelay: 500,
    /**
     * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
     * filter queries will execute with page start and limit parameters.  Only applies when mode = 'remote' (defaults to 0)
     */
    pageSize: 0,
    /**
     * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus.  Only applies
     * when editable = true (defaults to false)
     */
    selectOnFocus:true,
    /**
     * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
     */
    queryParam: 'query',
    /**
     * @cfg {String} loadingText The text to display in the dropdown list while data is loading.  Only applies
     * when mode = 'remote' (defaults to 'Loading...')
     */
    loadingText: 'Loading...',
    /**
     * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
     */
    resizable: false,
    /**
     * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
     */
    handleHeight : 4,
    /**
     * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
     * traditional select (defaults to true)
     */
    editable: true,
    /**
     * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
     */
    allQuery: '',
    /**
     * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
     */
    mode: 'remote',
    /**
     * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
     * listWidth has a higher value)
     */
    minListWidth : 70,
    /**
     * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
     * allow the user to set arbitrary text into the field (defaults to false)
     */
    forceSelection:false,
    /**
     * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
     * if typeAhead = true (defaults to 250)
     */
    typeAheadDelay : 250,
    /**
     * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
     * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined). If this
     * defaut text is used, it means there is no value set and no validation will occur on this field.
     */

    /**
     * @cfg {Boolean} lazyInit True to not initialize the list for this combo until the field is focused (defaults to true)
     */
    lazyInit : true,
    initComponent : function(){
        Ext.app.SearchField.superclass.initComponent.call(this);
		      this.addEvents(
            /**
             * @event expand
             * Fires when the dropdown list is expanded
             * @param {Ext.app.SearchField} combo This combo box
             */
            'expand',
            /**
             * @event collapse
             * Fires when the dropdown list is collapsed
             * @param {Ext.app.SearchField} combo This combo box
             */
            'collapse',
            /**
             * @event beforeselect
             * Fires before a list item is selected. Return false to cancel the selection.
             * @param {Ext.app.SearchField} combo This combo box
             * @param {Ext.data.Record} record The data record returned from the underlying store
             * @param {Number} index The index of the selected item in the dropdown list
             */
            'beforeselect',
            /**
             * @event select
             * Fires when a list item is selected
             * @param {Ext.app.SearchField} combo This combo box
             * @param {Ext.data.Record} record The data record returned from the underlying store
             * @param {Number} index The index of the selected item in the dropdown list
             */
            'select',
            /**
             * @event beforequery
             * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's
             * cancel property to true.
             * @param {Object} queryEvent An object that has these properties:<ul>
             * <li><code>combo</code> : Ext.app.SearchField <div class="sub-desc">This combo box</div></li>
             * <li><code>query</code> : String <div class="sub-desc">The query</div></li>
             * <li><code>forceAll</code> : Boolean <div class="sub-desc">True to force "all" query</div></li>
             * <li><code>cancel</code> : Boolean <div class="sub-desc">Set to true to cancel the query</div></li>
             * </ul>
             */
            'beforequery'
        );
		 
		if(Ext.isArray(this.store)){
			if (Ext.isArray(this.store[0])){
				this.store = new Ext.data.SimpleStore({
				    fields: ['value','text'],
				    data: this.store
				});
		        this.valueField = 'value';
			}else{
				this.store = new Ext.data.SimpleStore({
				    fields: ['text'],
				    data: this.store,
				    expandData: true
				});
		        this.valueField = 'text';
			}
			this.displayField = 'text';
			this.mode = 'local';
		}

        this.selectedIndex = -1;
        if(this.mode == 'local'){
            if(this.initialConfig.queryDelay === undefined){
                this.queryDelay = 10;
            }
            if(this.initialConfig.minChars === undefined){
                this.minChars = 0;
            }
        }
       
    },
	onRender : function(ct, position){
        Ext.app.SearchField.superclass.onRender.call(this, ct, position);
        if(Ext.isGecko){
            this.el.dom.setAttribute('autocomplete', 'off');
        }

        if(!this.lazyInit){
            this.initList();
        }else{
            this.on('focus', this.initList, this, {single: true});
        }

        if(!this.editable){
            this.editable = true;
            this.setEditable(false);
        }
    },
	 // private
    initList : function(){
        if(!this.list){
            var cls = 'x-combo-list';

            this.list = new Ext.Layer({
                shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
            });

            var lw = this.listWidth || Math.max(this.el.getWidth()-5, this.minListWidth);
            this.list.setWidth(lw);
            this.list.swallowEvent('mousewheel');
            this.assetHeight = 0;

            if(this.title){
                this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
                this.assetHeight += this.header.getHeight();
            }

            this.innerList = this.list.createChild({cls:cls+'-inner'});
            this.innerList.on('mouseover', this.onViewOver, this);
            this.innerList.on('mousemove', this.onViewMove, this);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));

            if(this.pageSize){
                this.footer = this.list.createChild({cls:cls+'-ft'});
                this.pageTb = new Ext.PagingToolbar({
                    store:this.store,
                    pageSize: this.pageSize,
                    renderTo:this.footer
                });
                this.assetHeight += this.footer.getHeight();
            }

            if(!this.tpl){
                /**
                * @cfg {String/Ext.XTemplate} tpl The template string, or {@link Ext.XTemplate}
                * instance to use to display each item in the dropdown list. Use
                * this to create custom UI layouts for items in the list.
                * <p>
                * If you wish to preserve the default visual look of list items, add the CSS
                * class name <pre>x-combo-list-item</pre> to the template's container element.
                * <p>
                * <b>The template must contain one or more substitution parameters using field
                * names from the Combo's</b> {@link #store Store}. An example of a custom template
                * would be adding an <pre>ext:qtip</pre> attribute which might display other fields
                * from the Store.
                * <p>
                * The dropdown list is displayed in a DataView. See {@link Ext.DataView} for details.
                */
                this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
                /**
                 * @cfg {String} itemSelector
                 * <b>This setting is required if a custom XTemplate has been specified in {@link #tpl}
                 * which assigns a class other than <pre>'x-combo-list-item'</pre> to dropdown list items</b>.
                 * A simple CSS selector (e.g. div.some-class or span:first-child) that will be
                 * used to determine what nodes the DataView which handles the dropdown display will
                 * be working with.
                 */
            }

            /**
            * The {@link Ext.DataView DataView} used to display the ComboBox's options.
            * @type Ext.DataView
            */
            this.view = new Ext.DataView({
                applyTo: this.innerList,
                tpl: this.tpl,
                singleSelect: true,
                selectedClass: this.selectedClass,
                itemSelector: this.itemSelector || '.' + cls + '-item'
            });

            this.view.on('click', this.onViewClick, this);

            this.bindStore(this.store, true);

            if(this.resizable){
                this.resizer = new Ext.Resizable(this.list,  {
                   pinned:true, handles:'se'
                });
                this.resizer.on('resize', function(r, w, h){
                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
                    this.listWidth = w;
                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
                    this.restrictHeight();
                }, this);
                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
            }
        }
    },

    // private
    bindStore : function(store, initial){
        if(this.store && !initial){
            this.store.un('beforeload', this.onBeforeLoad, this);
            this.store.un('load', this.onLoad, this);
            this.store.un('loadexception', this.collapse, this);
            if(!store){
                this.store = null;
                if(this.view){
                    this.view.setStore(null);
                }
            }
        }
        if(store){
            this.store = Ext.StoreMgr.lookup(store);

            this.store.on('beforeload', this.onBeforeLoad, this);
            this.store.on('load', this.onLoad, this);
            this.store.on('loadexception', this.collapse, this);

            if(this.view){
                this.view.setStore(store);
            }
        }
    },

    // private
    initEvents : function(){
        Ext.app.SearchField.superclass.initEvents.call(this);

        this.keyNav = new Ext.KeyNav(this.el, {
            "up" : function(e){
                this.inKeyMode = true;
                this.selectPrev();
            },

            "down" : function(e){
                if(!this.isExpanded()){
                    this.onTriggerClick();
                }else{
                    this.inKeyMode = true;
                    this.selectNext();
                }
            },

            "esc" : function(e){
                this.collapse();
            },
            scope : this,

            doRelay : function(foo, bar, hname){
                if(hname == 'down' || this.scope.isExpanded()){
                   return Ext.KeyNav.prototype.doRelay.apply(this, arguments);
                }
                return true;
            }
        });
        this.queryDelay = Math.max(this.queryDelay || 10,
                this.mode == 'local' ? 10 : 250);
        this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
        if(this.typeAhead){
            this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
        }
        if(this.editable !== false){
            this.el.on("keyup", this.onKeyUp, this);
        }
        if(this.forceSelection){
            this.on('blur', this.doForce, this);
        }
		
	
	
    },

    // private
    onDestroy : function(){
        if(this.view){
            this.view.el.removeAllListeners();
            this.view.el.remove();
            this.view.purgeListeners();
        }
        if(this.list){
            this.list.destroy();
        }
        this.bindStore(null);
        Ext.app.SearchField.superclass.onDestroy.call(this);
    },


    // private
    unsetDelayCheck : function(){
        delete this.delayedCheck;
    },

    // private
    fireKey : function(e){
		
		var v = this.getRawValue();
		
		if (v.length > 0) {
			var key =e.getKey()
			if(key == e.ENTER){  
				this.onViewClick();
			 	
			 }	 
			            
		   
			this.hasSearch = true;
		    this.triggers[0].show();
       }
			 
			 
        if(e.isNavKeyPress() && !this.isExpanded() && !this.delayedCheck){
            this.fireEvent("specialkey", this, e);
        }
    },
	
	    // private
    onResize: function(w, h){
        Ext.app.SearchField.superclass.onResize.apply(this, arguments);
        if(this.list && this.listWidth === undefined){
            var lw = Math.max(w, this.minListWidth);
            this.list.setWidth(lw);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
        }
    },
	
	// private
    onBeforeLoad : function(){
        if(!this.hasFocus){
            return;
        }
        this.innerList.update(this.loadingText ?
               '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
        this.restrictHeight();
        this.selectedIndex = -1;
    },
	
    // private
    onTypeAhead : function(){
        if(this.store.getCount() > 0){
            var r = this.store.getAt(0);
            var newValue = r.data[this.displayField];
            var len = newValue.length;
			var value = this.getRawValue();
            var selStart = value.length;
            if(selStart != len ){
                this.setRawValue(newValue);
                this.selectText(selStart, newValue.length);
            }
        }
    },

    // private
    onSelect : function(record, index){
        if(this.fireEvent('beforeselect', this, record, index) !== false){
            this.setValue(record.data[this.valueField || this.displayField]);
            this.collapse();
            this.fireEvent('select', this, record, index);			 
        }
    },

    /**
     * Returns the currently selected field value or empty string if no value is set.
     * @return {String} value The selected value
     */
    getValue : function(){
        if(this.valueField){
            return typeof this.value != 'undefined' ? this.value : '';
        }else{
            return Ext.app.SearchField.superclass.getValue.call(this);
        }
    },

    /**
     * Clears any text/value currently set in the field
     */
	
	setEmptyText:function(value){
		
			this.setRawValue('');
       		this.lastSelectionText = '';
			this.blur();
			this.emptyText =value;
		
			this.applyEmptyText();
		
        
		
	},
    clearValue : function(){
        if(this.hiddenField){
            this.hiddenField.value = '';
        }
		
		this.setValue('');
        this.setRawValue('');
        this.lastSelectionText = '';
		this.value = '';
        this.applyEmptyText();
		
       
    },

    /**
     * Sets the specified value into the field.  If the value finds a match, the corresponding record text
     * will be displayed in the field.  If the value does not match the data value of an existing item,
     * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
     * Otherwise the field will be blank (although the value will still be set).
     * @param {String} value The value to match
     */
    setValue : function(v){
        var text = v;
        if(this.valueField){
            var r = this.findRecord(this.valueField, v);
            if(r){
                text = r.data[this.displayField];
				this.onTrigger2Click();
            }else if(this.valueNotFoundText !== undefined){
                text = this.valueNotFoundText;
            }
        }
        this.lastSelectionText = text;
        if(this.hiddenField){
            this.hiddenField.value = v;
        }
        Ext.app.SearchField.superclass.setValue.call(this, text);
        this.value = v;
    },

    // private
    findRecord : function(prop, value){
       if (value !== undefined) {
	   
	   	var record;
	   	if (this.store.getCount() > 0) {
	   		this.store.each(function(r){
	   			if (r.data[prop].toLowerCase() == value.toLowerCase()) {
	   				record = r;
	   				return false;
	   			}
	   		});
	   	}
	   	return record;
	   }
    },

    // private
    onViewMove : function(e, t){
        this.inKeyMode = false;
    },

    // private
    onViewOver : function(e, t){
        if(this.inKeyMode){ // prevent key nav and mouse over conflicts
            return;
        }
        var item = this.view.findItemFromChild(t);
        if(item){
            var index = this.view.indexOf(item);
			 this.view.select(index);
        }
    },

    // private
    onViewClick : function(doFocus){
        var index = this.view.getSelectedIndexes()[0];
        var r = this.store.getAt(index);
        if(r){
            this.onSelect(r, index);
        }
        if(doFocus !== false){
            this.el.focus();
        }
		this.onTrigger2Click();
    },

    // private
    restrictHeight : function(){
        this.innerList.dom.style.height = '';
        var inner = this.innerList.dom;
        var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight;
        var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
        var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;
		if(this.getSize() &&  this.getSize().height){
			 var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;
		}else{
			 var hb = Ext.lib.Dom.getViewHeight();
		}
       
        var space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
        h = Math.min(h, space, this.maxHeight);

        this.innerList.setHeight(h);
        this.list.beginUpdate();
        this.list.setHeight(h+pad);
        this.list.alignTo(this.wrap, this.listAlign);
        this.list.endUpdate();
    },

    // private
    onEmptyResults : function(){
        this.collapse();
    },

    /**
     * Returns true if the dropdown list is expanded, else false.
     */
    isExpanded : function(){
        return this.list && this.list.isVisible();
    },

    /**
     * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
     * @param {String} value The data value of the item to select
     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
     * selected item if it is not currently in view (defaults to true)
     * @return {Boolean} True if the value matched an item in the list, else false
     */
    selectByValue : function(v, scrollIntoView){
        if(v !== undefined && v !== null){
            var r = this.findRecord(this.valueField || this.displayField, v);
            if(r){
                this.select(this.store.indexOf(r), scrollIntoView);
                return true;
            }
        }
        return false;
    },

    /**
     * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
     * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
     * @param {Number} index The zero-based index of the list item to select
     * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
     * selected item if it is not currently in view (defaults to true)
     */
    select : function(index, scrollIntoView){
        this.selectedIndex = index;
        this.view.select(index);
        if(scrollIntoView !== false){
            var el = this.view.getNode(index);
            if(el){
                this.innerList.scrollChildIntoView(el, false);
            }
        }
    },

    // private
    selectNext : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex < ct-1){
                this.select(this.selectedIndex+1);
            }
        }
    },

    // private
    selectPrev : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex != 0){
                this.select(this.selectedIndex-1);
            }
        }
    },

    // private
    onKeyUp : function(e){
        if(this.editable !== false && !e.isSpecialKey()){
            this.lastKey = e.getKey();
            this.dqTask.delay(this.queryDelay);			
        }
    },

    // private
    validateBlur : function(){
        return !this.list || !this.list.isVisible();
    },

    // private
    initQuery : function(){
        this.doQuery(this.getRawValue());
    },

    // private
    doForce : function(){
        if(this.el.dom.value.length > 0){
            this.el.dom.value =
                this.lastSelectionText === undefined ? '' : this.lastSelectionText;
            this.applyEmptyText();
        }
    },

    /**
     * Execute a query to filter the dropdown list.  Fires the {@link #beforequery} event prior to performing the
     * query allowing the query action to be canceled if needed.
     * @param {String} query The SQL query to execute
     * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
     * in the field than the minimum specified by the minChars config option.  It also clears any filter previously
     * saved in the current store (defaults to false)
     */

    doQuery : function(q, forceAll){
        if(q === undefined || q === null){
            q = '';
        }
        var qe = {
            query: q,
            forceAll: forceAll,
            combo: this,
            cancel:false
        };
        if(this.fireEvent('beforequery', qe)===false || qe.cancel){
            return false;
        }
        q = qe.query;
        forceAll = qe.forceAll;
        if(forceAll === true || (q.length >= this.minChars)){
            if(this.lastQuery !== q){
                this.lastQuery = q;
                if(this.mode == 'local'){
                    this.selectedIndex = -1;
                    if(forceAll){
                        this.store.clearFilter();
                    }else{
                        this.store.filter(this.displayField, q);
                    }
				
						this.onLoad();
				
                }else{
                    this.store.baseParams[this.queryParam] = q;
                    this.store.load({
                        params: this.getParams(q)
                    });
					
					
						this.expand();
					
                }
            }else{
                this.selectedIndex = -1;
                this.onLoad();
            }
        }
    },


    // private
    getParams : function(q){
        var p = {};
        //p[this.queryParam] = q;
        if(this.pageSize){
            p.start = 0;
            p.limit = this.pageSize;
        }
        return p;
    },

    /**
     * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.
     */
    collapse : function(){
        
        this.list.hide();
        Ext.getDoc().un('mousewheel', this.collapseIf, this);
        Ext.getDoc().un('mousedown', this.collapseIf, this);
        this.fireEvent('collapse', this);
    },

    // private
    collapseIf : function(e){
        if(!e.within(this.wrap) && !e.within(this.list)){
            this.collapse();
        }
    },

    /**
     * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.
     */
    expand : function(){
        if(this.isExpanded() || !this.hasFocus){
            return;
        }
        this.list.alignTo(this.wrap, this.listAlign);
        this.list.show();
        this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac
        Ext.getDoc().on('mousewheel', this.collapseIf, this);
        Ext.getDoc().on('mousedown', this.collapseIf, this);
        this.fireEvent('expand', this);
    },	//Configuration de la combobox
     

    
    // private
    onLoad : function(){
        if(!this.hasFocus){
            return;
        }
        		
        if (this.store.getCount() > 0 && this.el.dom.value!='') {
		
			this.expand();
			this.restrictHeight();
			
		}
		// si le store est vide on dit qu'il n'y a pas de résultats
		else {
			this.collapse();
		}		
		
    },


    

	handler:function(){
		
	},
    trigger1Class:'x-form-clear-trigger',
    trigger2Class:'x-form-search-trigger',
    hideTrigger1:true,
    width:180,
    hasSearch : false,
    paramName : 'query',

    onTrigger1Click : function(){
        if(this.hasSearch){
          
			this.el.focus();
            var o = {start: 0};  
			this.setValue(" ");          
            this.triggers[0].hide();
            this.hasSearch = false;
        }
    },

    onTrigger2Click : function(){
		
        var v = this.getRawValue();
        if(v.length < 1){
            this.onTrigger1Click();
            return;
        }
        var o = {start: 0};
        this.hasSearch = true;
        this.triggers[0].show();
		this.handler();
		this.collapse();
		
	 }
});/**
 * @author kalum
 */
/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 *
 * http://extjs.com/license
 */
Ext.grid.RowExpander = function(config) {
	Ext.apply(this, config);
	
	this.addEvents({
		beforeexpand: true,
		expand: true,
		beforecollapse: true,
		collapse: true
	});
	
	Ext.grid.RowExpander.superclass.constructor.call(this);
	
	if (this.tpl) {
		if (typeof this.tpl == 'string') {
			this.tpl = new Ext.Template(this.tpl);
		}
		this.tpl.compile();
	}
	
	this.state = {};
	this.bodyContent = {};
};

Ext.extend(Ext.grid.RowExpander, Ext.util.Observable, {
	header: "",
	width: 20,
	sortable: false,
	fixed: true,
	menuDisabled: true,
	dataIndex: '',
	id: 'expander',
	lazyRender: true,
	enableCaching: true,
	showText:false,
	
	getRowClass: function(record, rowIndex, p, ds) {
		p.cols = p.cols ;
		var content = this.bodyContent[record.id];
		
			if (!content && !this.lazyRender) {
			content = this.getBodyContent(record, rowIndex);
		}
		if (content) {
			p.body = content;
		}
		
	

		return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
	},
	
	init: function(grid) {
		this.grid = grid;
		
		var view = grid.getView();
		view.getRowClass = this.getRowClass.createDelegate(this);
		
		view.enableRowBody = true;
	},
	
	getBodyContent: function(record, index) {
		if (!this.enableCaching) {
			return this.tpl.apply(record.data);
		}
		var content = this.bodyContent[record.id];
		if (!content) {
			content = this.tpl.apply(record.data);
			this.bodyContent[record.id] = content;
		}
		return content;
	},
	
	getRemoteDataMethod: function(record, index) {
		if (!this.remoteDataMethod) {
			return;
		}
		return this.remoteDataMethod.call(this.remoteDataScope || this, this, record, index);
	},
		
	renderer: function(v, p, record) {
		p.cellAttr = 'rowspan="2"';
		return '<div class="x-grid3-row-expander">&#160;</div>';
	},
	
	beforeExpand: function(record, body, rowIndex) {
		if (this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false) {
		
			if (this.tpl && this.lazyRender) {
				body.innerHTML = this.getBodyContent(record, rowIndex);
			}
			return true;
		} else {
			return false;
		}
	},
	
	toggleRow: function(row) {
		if (typeof row == 'number') {
			row = this.grid.view.getRow(row);
		}
		this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
	},
	
	expandRow: function(row) {
		if (this.expandedRow) {
			this.collapseRow(this.expandedRow);
		}
		this.expandedRow = row;
		if (typeof row == 'number') {
			row = this.grid.view.getRow(row);
		}
		var record = this.grid.store.getAt(row.rowIndex);
		var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
		if (this.beforeExpand(record, body, row.rowIndex)) {
			this.state[record.id] = true;
			Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
			this.fireEvent('expand', this, record, body, row.rowIndex);
			if (body) {
				body.innerHTML = "";
			}
			if (this.remoteDataMethod) {
				this.remoteDataMethod.call(this.remoteDataScope || this, this, record, row, body);
			}
			
		}
	},
	
	collapseRow: function(row) {
		if (this.grid) {
			if (typeof row == 'number') {
				row = this.grid.view.getRow(row);
			}
			
			var record = this.grid.store.getAt(row.rowIndex);
			var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
			if (this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false) {
				this.state[record.id] = false;
				Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
				this.fireEvent('collapse', this, record, body, row.rowIndex);
			}
			
		}
	}
});

Ext.tree.TreeNodeUILeft = Ext.extend(Ext.tree.TreeNodeUI, {
     // private
    renderElements : function(n, a, targetNode, bulkRender){
        // add some indent caching, this helps performance when rendering a large tree
        this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';

        var cb = typeof a.checked == 'boolean';

        var href = a.href ? a.href : Ext.isGecko ? "" : "#";
        var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
            '<span class="x-tree-node-indent"></span>',
            '<img src="', this.emptyIcon, '" />',
            '<img src="', a.icon || this.emptyIcon, '" unselectable="on" />',
            cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
            '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
             a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on" style="width:\'auto\'; overflow:\'hidden\'">',n.text,
			 
			 "</span></a>",
			   '<img src="', this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" />',		
			 
			 "</div>",

            '<ul class="x-tree-node-ct" style="display:none;"></ul>',
			
            "</li>"].join('');

        var nel;
        if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
            this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
        }else{
            this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
        }
        
        this.elNode = this.wrap.childNodes[0];
        this.ctNode = this.wrap.childNodes[1];
        var cs = this.elNode.childNodes;
        this.indentNode = cs[0];
        this.ecNode = cs[1];
        this.iconNode = cs[2];
        var index = 3;
        if(cb){
            this.checkbox = cs[3];
			// fix for IE6
			this.checkbox.defaultChecked = this.checkbox.checked;			
            index++;
        }
        this.anchor = cs[index];
        this.textNode = cs[index].firstChild;
    },
	   // private
    onClick : function(e){
        if(this.dropping){
            e.stopEvent();
            return;
        }
        if(this.fireEvent("beforeclick", this.node, e) !== false){
            var a = e.getTarget('a');
            if(!this.disabled && this.node.attributes.href && a){
                this.fireEvent("click", this.node, e);
                return;
            }else if(a && e.ctrlKey){
                e.stopEvent();
            }
            e.preventDefault();
            if(this.disabled){
                return;
            }

            if(!this.animating && this.node.isExpandable()){
                this.node.toggle();
            }
			

            this.fireEvent("click", this.node, e);
        }else{
            e.stopEvent();
        }
    }

 
	
	});Ext.namespace('Ext.ux.dd');

Ext.ux.dd.GridReorderDropTarget = function(grid, config)
{
    this.target = new Ext.dd.DropTarget(grid.getEl(),
    {
        ddGroup: 'GridDD',
        grid: grid,
        gridDropTarget: this,
        notifyDrop: function(dd, e, data)
        {
            // Remove drag lines. The 'if' condition prevents null error when drop occurs without dragging out of the selection area
            if (this.currentRowEl)
            {
                this.currentRowEl.removeClass('grid-row-insert-below');
                this.currentRowEl.removeClass('grid-row-insert-above');
            }

            // determine the row
            var t = Ext.lib.Event.getTarget(e);
            var rindex = this.grid.getView().findRowIndex(t);
			
			 if (this.copy) 
            {
				if(rindex === false){
					rindex=1;
				}
				
            }
			
            if (rindex === false || rindex == data.rowIndex)
            {
                return false;
            }
            // fire the before move/copy event
            if (this.gridDropTarget.fireEvent( 'beforerowmove', this.gridDropTarget, data.rowIndex, rindex, data.selections, 123) === false)
            {
                return false;
            }

            // update the store
            var ds = this.grid.getStore();

            // Changes for multiselction by Spirit
            var selections = new Array();
    
			
			
			selections.push(ds.getAt(data.rowIndex));

            // we tried to move this node before the next sibling, we stay in place
            if (rindex == data.rowIndex)
            {
                return false;
            }

            // fire the before move/copy event
            /* dupe - does it belong here or above???
            if (this.gridDropTarget.fireEvent(this.copy ? 'beforerowcopy' : 'beforerowmove', this.gridDropTarget, data.rowIndex, rindex, data.selections, 123) === false)
            {
                return false;
            }
            */
			



            if (!this.copy) 
            {
               	ds.remove(ds.getAt(data.rowIndex));	
				ds.insert(rindex, selections[0]);
            }
			
			
			
			  // re-select the row(s)
          var sm = this.grid.getSelectionModel();
          if (sm) sm.selectRecords(data.selections);
		  
		  
            // fire the after move/copy event
            this.gridDropTarget.fireEvent( 'afterrowmove', this.gridDropTarget, data.rowIndex, rindex, data.selections);
            return true;
        },
        notifyOver: function(dd, e, data) 
        {
            var t = Ext.lib.Event.getTarget(e);
            var rindex = this.grid.getView().findRowIndex(t);
			
			
			
			if(t.qtip){
				if(t.qtip.nodeName ="BUTTON"){
					
					var page = parseInt(t.innerHTML);
					if(page){
						
						if(J.fc.tbar){
							J.fc.tbar.onClick(page);
						}
						
					}
					
				}
			}

            // Similar to the code in notifyDrop. Filters for selected rows and quits function if any one row matches the current selected row.
            var ds = this.grid.getStore();
            var keys = ds.data.keys;
            for (var key in keys) 
            {
                for (var i = 0; i < data.selections.length; i++) 
                {
                    if (keys[key] == data.selections[i].id) 
                    {
                        if (rindex == key) 
                        {
                            if (this.currentRowEl) 
                            {
                                this.currentRowEl.removeClass('grid-row-insert-below');
                                this.currentRowEl.removeClass('grid-row-insert-above');
                            }
                            return this.dropNotAllowed;
                        }
                    }
                }
            }
			
			

            // If on first row, remove upper line. Prevents negative index error as a result of rindex going negative.
            if (rindex < 0 || rindex === false) 
            {
                if (this.currentRowEl) {
					this.currentRowEl.removeClass('grid-row-insert-above');
					return this.dropNotAllowed;
					
				}
            }

            try 
            {
                var currentRow = this.grid.getView().getRow(rindex);
                // Find position of row relative to page (adjusting for grid's scroll position)
                var resolvedRow = new Ext.Element(currentRow).getY() - this.grid.getView().scroller.dom.scrollTop;
                var rowHeight = currentRow.offsetHeight;

                // Cursor relative to a row. -ve value implies cursor is above the row's middle and +ve value implues cursor is below the row's middle.
                this.rowPosition = e.getPageY() - resolvedRow - (rowHeight/2);

                // Clear drag line.
                if (this.currentRowEl) 
                {
                    this.currentRowEl.removeClass('grid-row-insert-below');
                    this.currentRowEl.removeClass('grid-row-insert-above');
                }

                if (this.rowPosition > 0) 
                {
                    // If the pointer is on the bottom half of the row.
                    this.currentRowEl = new Ext.Element(currentRow);
                    this.currentRowEl.addClass('grid-row-insert-below');
                } 
                else 
                {
                    // If the pointer is on the top half of the row.
                    if (rindex - 1 >= 0) 
                    {
                        var previousRow = this.grid.getView().getRow(rindex - 1);
                        this.currentRowEl = new Ext.Element(previousRow);
                        this.currentRowEl.addClass('grid-row-insert-below');
                    } 
                    else 
                    {
                        // If the pointer is on the top half of the first row.
                       if (this.currentRowEl) {
					   	this.currentRowEl.addClass('grid-row-insert-above');
					   }
                    }
                }
            } 
            catch (err) 
            {
                console.warn(err);
                rindex = false;
            }
            return (rindex === false)? this.dropNotAllowed : this.dropAllowed;
        },
        notifyOut: function(dd, e, data) 
        {
            // Remove drag lines when pointer leaves the gridView.
            if (this.currentRowEl) 
            {
                this.currentRowEl.removeClass('grid-row-insert-above');
                this.currentRowEl.removeClass('grid-row-insert-below');
            }
        }
    });

    if (config) 
    {
        Ext.apply(this.target, config);
        if (config.listeners)
        {
            Ext.apply(this,
            {
              listeners: config.listeners
            });
        }
    }

    this.addEvents(
    {
        'beforerowmove': true,
        'afterrowmove': true,
        'beforerowcopy': true,
        'afterrowcopy': true
    });

    Ext.ux.dd.GridReorderDropTarget.superclass.constructor.call(this);
};    

Ext.extend(Ext.ux.dd.GridReorderDropTarget, Ext.util.Observable, 
{
    getTarget: function() 
    {
        return this.target;
    },
    getGrid: function() 
    {
        return this.target.grid;
    },
    getCopy: function() 
    {
        return this.target.copy ? true : false;
    },
    setCopy: function(b) 
    {
        this.target.copy = b ? true : false;
    }
});J.Problem = function() {
	return {
		hrefTo: function(p) {
			return J.Nav.hrefTo(['problem', Ext.encode(p)]);
		},
		
		/**
		 * Change the document location (which will call the show method)
		 * @param {Int} userId
		 * @param {Object} p
		 */
		go: function(p) {
			document.location = this.hrefTo(p);
		},
		
		show: function(p) {
			p = p||{};
			new J.Popup({
				requireLogin: true,
				title: tr('problem_header'),
				trackController: 'problem',
				trackAction: p.objCls,
				trackId: p.objId,
				msg: tr('problem_msg'),
				submit: {url: '/problem/add'},
				success: this.respProblem,
				scope: this,
				fields:
				[
					{
						type: 'hidden',
						name: 'objType',
						value: p.objCls
					},
					{
						type: 'hidden',
						name: 'objId',
						value: p.objId
					},
					{
						type: 'textArea',
						fieldLabel: tr('problem_label_description'),
						name: 'body',
						maxLength: 255
					}
				]
			});
		},
		respProblem: function(problem) {
			Ext.MessageBox.alert(tr('problem_header'), tr('problem_success_msg', problem.problemId));
		}
	};
}();/**
 * @class Ext.ux.SliderTip
 * @extends Ext.Tip Simple plugin for using an Ext.Tip with a slider to show the
 *          slider value
 */
Ext.ux.SliderTip = Ext.extend(Ext.Tip, {

	minWidth : 10,

	offsets : [0, -10],

	init : function(slider) {

		slider.on('dragstart', this.onSlide, this);

		slider.on('drag', this.onSlide, this);

		slider.on('dragend', this.hide, this);

		slider.on('destroy', this.destroy, this);

	},

	onSlide : function(slider) {

		this.show();

		this.body.update(this.getText(slider));

		this.doAutoWidth();

		this.el.alignTo(slider.thumb, 'b-t?', this.offsets);

	},

	getText : function(slider) {

		return slider.getValue();

	}

});


J.WizardPlaylist = function() {
	return {
		slide : [],
		ready : false,
		/**
		 * Module name
		 */
		moduleName : 'Wizard Playlist',

		/**
		 * Returns the module url.
		 */
		hrefTo : function(songId) {
			return J.Nav.hrefTo(['wizardPlaylist', songId]);
		},

		compact : true,
		/**
		 * Changes the document location (which will call the show method)
		 */
		go : function() {
			document.location = this.hrefTo();
		},

		/**
		 * Name.
		 */
		name : '',

		/**
		 * Expert mode.
		 */
		id : null,

		script : false,
		/**
		 * Permalien.
		 */
		permalink : '',

		/**
		 * Domain.
		 */
		domain : '',

		steps : 0,

		stepText : "Step {0} of {1}: {2}",
		/**
		 * @param {Ext.Element}
		 */
		titleEl : null,

		/**
		 * @param {Ext.Element}
		 */
		stepEl : null,

		/**
		 * @param {Ext.Element}
		 */
		imageContainer : null,

		/**
		 * @param {Array}
		 */
		indicators : null,

		/**
		 * @param {Ext.Template}
		 */
		stepTemplate : null,

		/**
		 * @param {Number}
		 *            lastActiveStep Stores the index of the last active card
		 *            that was shown-
		 */
		lastActiveStep : -1,
		/**
		 * flashvars.
		 */
		flash : {

			vars : {
				wizard : true,
				widgetURL : 'http://' + location.hostname
						+ '/res/widget/compact.swf'
			}

		},

		/**
		 * Shows the module in the "Content" zone.
		 */

		show : function(config) {

			if (config.permalink !== undefined) {
				this.flash.vars.permalink = config.permalink;
			}

			if (config.name !== undefined) {
				this.flash.vars.name = config.name;
			}

			if (config.id !== undefined) {
				this.id = config.id;
			}

			if (config.domain !== undefined) {

				this.domain = config.domain;

				delete this.flash.vars.playlistId;
				delete this.flash.vars.albumId;
				delete this.flash.vars.artistId;

			}
			
		if(!this.script){
			var script = document.createElement("script");
            script.setAttribute("src", "http://cdn.gigya.com/wildfire/js/wfapiv2.js");
            script.setAttribute("type", "text/javascript");  
            document.getElementsByTagName("head")[0].appendChild(script);
			this.script=true;
		}

			//console.error("oh", this.flash.vars);

			switch (this.domain) {

				case 'playlist' : {
					this.flash.vars.playlistId = this.id;
				}
					break;

				case 'album' : {
					this.flash.vars.albumId = this.id;

				}
					break;

				case 'artist' : {
					this.flash.vars.artistId = this.id
				}
				break;

			}

	
			var skins = [{
				skinId : "bright",
				name : "Bright"
			}, {
				skinId : "originel",
				name : "Originel"
			}];

			this.size =new Ext.form.RadioGroup({
				 xtype: 'radiogroup',
				 anchor: '95%',
				hideLabel : true,
				allowBlank : false,
				items : [{
					columnWidth: '1',					
					items : [{
						xtype : 'label',
						text : 'Taille',
						cls : 'x-form-check-group-label'
					}, {
						boxLabel : 'Version Compact (160 x 240 px)',
						name : 'size',
						checked : true,
						width : 300,
						id : 'check-compact',
						inputValue : 'compact',
						listeners : {
							'check' : this.onSizeChange
						}
					}, {
						boxLabel : 'Version Large (200 x 310 px)',
						name : 'size',
						id : 'check-large',
						width : 300,
						inputValue : 'large',
						listeners : {
							'check' : this.onSizeChange
						}
					}]
				}]
			});

			this.skin = new Ext.form.RadioGroup({
				itemCls : 'x-check-group-alt',
				hideLabel : true,
				allowBlank : false,
				items : [{
					items : [{
						xtype : 'label',
						text : 'Skin',
						cls : 'x-form-check-group-label'
					}, {
						boxLabel : 'Bright',
						name : 'skin',

						checked : true,
						id : 'check-bright',
						inputValue : 'bright',
						listeners : {
							'check' : this.onSkinChange

						}
					}, {
						boxLabel : 'Originel',
						name : 'skin',

						id : 'check-originel',
						inputValue : 'originel',
						listeners : {
							'check' : this.onSkinChange
						}
					}]
				}]
			});

			this.colorsEls = [];

			this.slide['red'] = new Ext.Slider({
				width : 200,
				id : 'wizard-red',
				minValue : 0,
				maxValue : 255,
				plugins : new Ext.ux.SliderTip(),
				listeners : {
					'change' : function() {
						J.WizardPlaylist.ColorChange();
					}
				}
			});

			this.slide['green'] = new Ext.Slider({
				width : 200,
				id : 'wizard-green',
				minValue : 0,
				maxValue : 255,
				plugins : new Ext.ux.SliderTip(),
				listeners : {
					'change' : function() {
						J.WizardPlaylist.ColorChange();
					}
				}
			});

			this.slide['blue'] = new Ext.Slider({
				width : 200,
				id : 'wizard-blue',
				minValue : 0,
				maxValue : 255,
				plugins : new Ext.ux.SliderTip(),
				listeners : {
					'change' : function() {
						J.WizardPlaylist.ColorChange();
					}
				}
			});
			
			var cards = [{
				headtitle : 'Choisissez le Look de votre widget',
				xtype : 'form',
				id : 'card-0',
				border : false,
				bodyStyle : 'background:none;',
				defaults : {
					labelStyle : 'font-size:11px'
				},
				items : [{
					xtype : 'fieldset',
					height : 70,					
					bodyStyle : 'padding:10px;',
					title : 'Blog, FaceBook, Myspace, etc ....',
					items : [{
						border : false,
						html : 'Intégrez simplement le lecteur exportable JIWA personnalisé sur votre Blog, Bureau, Facebook, Myspace etc... en quelques clics'
					}]
				}, {
					xtype : 'fieldset',
					height : 380,
					bodyStyle : 'padding:20px;',
					title : 'Votre Look',
					items : [this.size, this.skin]
				}]
			}, {
				headtitle : 'Choisissez la Couleur de votre widget',
				id : 'card-1',
				border : false,
				items : [{
					xtype : 'fieldset',
					height : 225,
					title : 'Teinte',
					items : [{
						xtype : 'colorpicker',
						title : 'ColorPicker',
						id : 'panelPicker',
						listeners : {
							'pickcolor' : function() {
								J.WizardPlaylist.ColorChange();
							}
						}
					}]
				}, {
					xtype : 'fieldset',
					height : 225,
					title : 'Niveaux de Couleurs',
					layout : 'table',
					bodyStyle : 'padding:10px;',
					layoutConfig : {
						columns : 2
					},
					items : [{
						width : 280,
						border : false,
						items : [{
							cls : 'wizard-slide-title',
							html : 'Ajouter du Rouge'
						}, this.slide['red'], {
							cls : 'wizard-slide-title',
							html : 'Ajouter du Vert'
						}, this.slide['green'], {
							cls : 'wizard-slide-title',
							html : 'Ajouter du Bleu'
						}, this.slide['blue']]
					}, {
						border : false,
						style : 'text-align:center',
						items : {
							xtype : "button",
							style : 'padding:10px',
							text : "Valeurs par défauts",
							listeners : {
								'click' : function() {
									
									J.WizardPlaylist.setDefaultRGB();
							
								}
							}
						}

					}]

				}]
			}, {
				headtitle : 'Choisissez les Couleurs des Textes de votre widget',
				id : 'card-2',
				border : false,
				items : [{
					xtype : 'fieldset',
					height : 225,
					title : 'Teinte',
					items : [{
						xtype : 'colorpicker',
						title : 'ColorPicker',
						id : 'panelPickerText',
						listeners : {
							'pickcolor' : function() {
								J.WizardPlaylist.TextColorChange();
							}
						}
					}]
				}]
			}, {
				headtitle : 'Copiez le Code ou Intégrez automatiquement le widget  sur votre site',
				id : 'card-3',
				border : false,
				style : 'margin-top: 15px;',
				bodyStyle : 'background:none;',
				defaults : {
					labelStyle : 'font-size:11px'
				},
				items : [{
					xtype : 'fieldset',					
					height : 500,
					title : 'Votre Code',
					items : [{
						html : '<div id="divWildfirePost"></div>'
					}]
				}],
				listeners : {
					'show' : function() {
						J.track('widget','wizard','multi');
						document.getElementById("code_embed_multitle").value = document
								.getElementById("jiwadgetWizard").jsGetCode();
											var pconf = {
												nowmode:true,
				includeShareButton : 'false',
				defaultContent : 'code_embed_multitle',
				UIConfig : '<config><display showDesktop="true" showEmail="false" showBookmark="false" showCloseButton="false" postToSidebarChecked="false" networksWithCodeBox=""></display></config>'
			};
			
			if(T.languageId){
				pconf.lang = 'fr';	
			}
			Wildfire.initPost('308341', 'divWildfirePost', 450, 350, pconf);
					}
				}
			}];

			var cardPanel = {
				region : 'center',
				layout : 'card',
				style : 'margin-top: 20px;',
				id : 'card-wizard-panel',
				border : false,
				activeItem : 0,
				items : cards
			};

			var LeftPanel = {
				region : 'west',
				id : 'widget-wizard-panel',
				width : 260,
				items : [{
					xtype : 'fieldset',
					title : 'Widget',
					height : 450,
					style : 'margin: 15px; padding-top: 10px;',
					width : 230,
					html : '<center><div id="jiwadgetWizard"></div></center><textarea id="code_embed_multitle" style="display:none"></textarea>'
				}]
			};

			this.wizard = new Ext.ux.Wiz({
				title : 'Widget MultiTitre',
				resizable : true,
				leftPanel : LeftPanel,
				cardPanelConfig : {
					defaults : {
						baseCls : 'x-small-editor',
						border : false
					}
				},
				cards : cards
			});

			this.wizard.show();

			swfobject.embedSWF("/res/widget/compact.swf", "jiwadgetWizard",
					"160", "245", "9.0.0", "/res/swf/expressinstall.swf",
					J.WizardPlaylist.flash.vars, J.WizardPlaylist.flash.params,
					J.WizardPlaylist.flash.attributes);
					
			this.colors = [{
				colorId : "title",
				value : '',
				name : "Titre du morceau",
				description : ""
			}, {
				colorId : "artist",
				value : '',
				name : "Artiste du morceau",
				description : ""
			}, {
				colorId : "time",
				value : '',
				name : "Temps",
				description : ""
			}, {
				colorId : "volumeBackground",
				value : '',
				name : "Fond de la barre de volume",
				description : ""
			}, {
				colorId : "volume",
				value : '',
				name : "Barre de volume",
				description : ""
			}, {
				colorId : "volumePreview",
				value : '',
				name : "Barre de volume (rollover)",
				description : ""
			}, {
				colorId : "progressBackground",
				value : '',
				name : "Fond de la barre de progression",
				description : ""
			}, {
				colorId : "arrows",
				value : '',
				name : "Flèches de la barre de progression",
				description : ""
			}, {
				colorId : "loadedBar",
				value : '',
				name : "Barre de progression",
				description : ""
			}, {
				colorId : "playedBar",
				value : '',
				name : "Barre de chargement",
				description : ""
			}, {
				colorId : "trackinfos",
				value : '',
				name : "Informations de la piste",
				description : ""
			}, {
				colorId : "comments",
				value : '',
				name : "Bouton commentaires",
				description : ""
			}, {
				colorId : "gotoplaylist",
				value : '',
				name : "Bouton accéder à ma playlist",
				description : ""
			}, {
				colorId : "songBars",
				value : '',
				name : "Titres de la playlist",
				description : ""
			}];


			var right = Ext.get('change-text-color');
			
			Ext.each(this.colors, function(color) {

				var wrapper = right.createChild({
					cls : "colorSetter"
				});

				wrapper.elColorName = wrapper.createChild({
					cls : "colorName",
					html : color.name
				});

				wrapper.elColorPreview = wrapper.createChild({
					cls : "colorPreview",
					style : "background-color:#" + color.value
				});

				wrapper.elColorCode = wrapper.createChild({
					cls : "colorCode",
					tag : "input",
					type : "text",
					value : color.value
				});

				wrapper.elColorCode.on("keyup", this.onColorValidated, this, {
					delay : 200,
					colorId : color.colorId
				});

				wrapper.elColorPreview.on("click", this.onColorMenuSelected,
						this, {
							colorId : color.colorId
						});

				wrapper.elColorCode.on("change", this.onColorValidated, this, {
					colorId : color.colorId
				});

				this.colorsEls[color.colorId] = wrapper;
			}, this);



		},

		/*
		 * Occurs when a color is selected in the menu.
		 * 
		 * @param colorMenu {Ext.menu.ColorMenu} The color menu
		 * 
		 * @param color {String} The color value (hexadecimal)
		 */
		onColorSelected : function(colorMenu, color) {

			if (typeof color === "string") {
				var wrapper = this.colorsEls[this.currentColorId];

				wrapper.elColorCode.dom.value = color;

				this.onColorValidated(null, null, {
					colorId : this.currentColorId
				});
			}

		},

		onColorValidated : function(ev, target, options) {
			var colorId = options.colorId;
			var color = options.color;

			var wrapper = this.colorsEls[colorId];

			if (options.color) {
				wrapper.elColorCode.dom.value = color = options.color;
			} else {
				color = wrapper.elColorCode.dom.value;
			}

			wrapper.elColorPreview.setStyle("background-color", "#" + color);

			document.getElementById("jiwadgetWizard")
					.jsSetColor(colorId, color);

			// this.

		},

		onColorRevert : function(ev, target, options) {
			var colorId = options.colorId;
			var defaultValue = options.defaultValue;

			this.onColorValidated(null, null, {
				colorId : colorId,
				color : defaultValue
			});
		},

		/*
		 * Occurs when the user click on the color menu. Should show the
		 * palette.
		 */
		onColorMenuSelected : function(ev, target, options) {
			var colorId = options.colorId;
			var wrapper = this.colorsEls[colorId];
			this.currentColorId = colorId;
			this.colorMenu = new Ext.menu.ColorMenu({
				handler : this.onColorSelected,
				scope : this
			});

			this.colorMenu.show(wrapper.elColorPreview);
		},

		/*
		 * Occurs when the player is ready. Insert the embed code in the
		 * textarea
		 */
		onReady : function() {

			this.ready = true;

			this.setDefaultRGB();
			this.setDefaultColors();
			

		},

		setDefaultColors : function() {

			var DefaultColors =document.getElementById("jiwadgetWizard").jsGetColors();

			this.colors = [{
				colorId : "title",
				value : DefaultColors.title,
				name : "Titre du morceau",
				description : ""
			}, {
				colorId : "artist",
				value : DefaultColors.artist,
				name : "Artiste du morceau",
				description : ""
			}, {
				colorId : "time",
				value : DefaultColors.time,
				name : "Temps",
				description : ""
			}, {
				colorId : "volumeBackground",
				value : DefaultColors.volumeBackground,
				name : "Fond de la barre de volume",
				description : ""
			}, {
				colorId : "volume",
				value : DefaultColors.volume,
				name : "Barre de volume",
				description : ""
			}, {
				colorId : "volumePreview",
				value : DefaultColors.volumePreview,
				name : "Barre de volume (rollover)",
				description : ""
			}, {
				colorId : "progressBackground",
				value : DefaultColors.progressBackground,
				name : "Fond de la barre de progression",
				description : ""
			}, {
				colorId : "arrows",
				value : DefaultColors.arrows,
				name : "Flèches de la barre de progression",
				description : ""
			}, {
				colorId : "loadedBar",
				value : DefaultColors.loadedBar,
				name : "Barre de progression",
				description : ""
			}, {
				colorId : "playedBar",
				value : DefaultColors.playedBar,
				name : "Barre de chargement",
				description : ""
			}, {
				colorId : "trackinfos",
				value : DefaultColors.trackinfos,
				name : "Informations de la piste",
				description : ""
			}, {
				colorId : "comments",
				value : DefaultColors.comments,
				name : "Bouton commentaires",
				description : ""
			}, {
				colorId : "gotoplaylist",
				value : DefaultColors.gotoplaylist,
				name : "Bouton accéder à ma playlist",
				description : ""
			}, {
				colorId : "songBars",
				value : DefaultColors.songBars,
				name : "Titres de la playlist",
				description : ""
			}];
			
			Ext.each(this.colors, function(color) {

				J.WizardPlaylist.onColorValidated(null, null, {
					colorId : color.colorId,
					color : color.value
				});
			}, this);

		},

		/*
		 * Occurs when a skin checkbox is checked.
		 * 
		 * @param checkbox {Ext.form.Checkbox} The checkbox. @param checked
		 * {Boolean} The new checkbox state.
		 */
		onSizeChange : function(checkbox, checked) {
			
			if (Ext.getCmp('check-bright').getValue()) {
				
					
				J.WizardPlaylist.flash.vars.skin= 'bright';
				
				}else{
					
				J.WizardPlaylist.flash.vars.skin= 'originel';
					
				}

			if (Ext.getCmp('check-compact').getValue()) {
				
				
				J.WizardPlaylist.flash.vars.widgetURL = 'http://' + location.hostname
						+ '/res/widget/compact.swf';
						
				
			
				swfobject.embedSWF("/res/widget/compact.swf", "jiwadgetWizard",
						"160", "245", "9.0.0", "/res/swf/expressinstall.swf",
						J.WizardPlaylist.flash.vars,
						J.WizardPlaylist.flash.params,
						J.WizardPlaylist.flash.attributes);
						
				Ext.getCmp('check-compact').setValue(true);	
				Ext.getCmp('check-large').setValue(false);

			} else {

				J.WizardPlaylist.flash.vars.widgetURL = 'http://' + location.hostname
						+ '/res/widget/multititle.swf';
					
				swfobject.embedSWF("/res/widget/multititle.swf",
						"jiwadgetWizard", "200", "310", "9.0.0",
						"/res/swf/expressinstall.swf",
						J.WizardPlaylist.flash.vars,
						J.WizardPlaylist.flash.params,
						J.WizardPlaylist.flash.attributes);
						
				Ext.getCmp('check-compact').setValue(false);	
				Ext.getCmp('check-large').setValue(true);

			}
			

		},

		/*
		 * Occurs when a skin checkbox is checked and apply the new skin to the player.
		 * 
		 * @param checkbox {Ext.form.Checkbox} The checkbox. @param checked
		 * {Boolean} The new checkbox state.
		 */
		onSkinChange : function() {

			if (Ext.getCmp('check-bright').getValue()) {

				document.getElementById("jiwadgetWizard").jsSetSkin('bright');

				Ext.getCmp('check-bright').setValue(true);	
				Ext.getCmp('check-originel').setValue(false);	
			} else {

				document.getElementById("jiwadgetWizard").jsSetSkin('originel');
						
				Ext.getCmp('check-bright').setValue(false);	
				Ext.getCmp('check-originel').setValue(true);	

			}
			
			J.WizardPlaylist.setDefaultColors();

		},

		/*
		 * Called by the Wizard Flash Player.
		 * 
		 * @param {Object} images
		 */
		notifyErrors : function(errors) {
			var title = '';
			var msg = '';
			Ext.each(errors, function(error) {
				if (error.type == "image_not_found") {
					title = error.type;
					msg += error.msg + '<br/>';
				}

			}, this);

			if (title != '') {
				Ext.Msg.alert(tr('WizardPlaylist_imageNotFound'), msg);
			}
		},
		/*
		 * Occurs when a color is selected and apply this color to the player.
		 * 
		 */
		ColorChange: function(){
        
          
            
            var redOffset = this.slide['red'].getValue();
            var greenOffset = this.slide['green'].getValue();
            var blueOffset = this.slide['blue'].getValue();
		 /*	
		  * 
			document.getElementById("jiwadgetWizard").jsSetSkinColor(hexa, 0, 0, 0);
       	 */
       
            var h = Ext.getCmp('panelPicker__iRed').getValue();
            var s = Ext.getCmp('panelPicker__iGreen').getValue();
            var v = Ext.getCmp('panelPicker__iBlue').getValue();
			
            document.getElementById("jiwadgetWizard").jsSetSkinColor(h,s,v, redOffset, greenOffset, blueOffset);
            
             
        },
        setDefaultRGB: function(){
        
            Ext.getCmp('panelPicker__iHexa').setValue('FFFFFF');
            Ext.get('panelPicker__cColor').dom.style.backgroundColor = '#FFFFFF';
          
            this.slide['red'].setValue(0);
            this.slide['green'].setValue(0);
            this.slide['blue'].setValue(0); 
			
            document.getElementById("jiwadgetWizard").jsSetSkinColor(3,3,3, redOffset, greenOffset, blueOffset);
            
         
          
            
        },
		TextColorChange: function(){
        
            var hexa = Ext.getCmp('panelPickerText__iHexa').getValue();
            
            document.getElementById("jiwadgetWizard").jsSetTextColor(hexa);
            
        },
        setTextDefaultRGB: function(){
        
            Ext.getCmp('panelPickerText__iHexa').setValue('FFFFFF');
            Ext.get('panelPickerText__cColor').dom.style.backgroundColor = '#FFFFFF';
            
            document.getElementById("jiwadgetWizard").jsSetTextColor('FFFFFF');
            
        }
	};
}();J.WizardSong = function(){
    return {
        slide: [],
        ready: false,
        /**
         * Module name
         */
        moduleName: 'Wizard Playlist',
        
        /**
         * Returns the module url.
         */
        hrefTo: function(songId){
            return J.Nav.hrefTo(['wizardSong', songId]);
        },
        /**
         * Changes the document location (which will call the show method)
         */
        go: function(){
            document.location = this.hrefTo();
        },
        
        /**
         * Name.
         */
        name: '',
        
        /**
         * Expert mode.
         */
        trackId: null,
        
        script: false,
        /**
         * Permalien.
         */
        permalink: '',
        
        /**
         * Domain.
         */
        domain: '',
        
        steps: 0,
        
        stepText: "Step {0} of {1}: {2}",
        /**
         * @param {Ext.Element}
         */
        titleEl: null,
        
        /**
         * @param {Ext.Element}
         */
        stepEl: null,
        
        /**
         * @param {Ext.Element}
         */
        imageContainer: null,
        
        /**
         * @param {Array}
         */
        indicators: null,
        
        /**
         * @param {Ext.Template}
         */
        stepTemplate: null,
        
        /**
         * @param {Number}
         *            lastActiveStep Stores the index of the last active card
         *            that was shown-
         */
        lastActiveStep: -1,
        /**
         * flashvars.
         */
        flash: {
        
            vars: {
                wizard: true,
                widgetURL: 'http://' + location.hostname +
                '/res/widget/monotitle.swf'
            },
            params: {
                wmode: 'transparent'
            }
        
        },
        
        /**
         * Shows the module in the "Content" zone.
         */
        show: function(config){
        
            if (config.permalink !== undefined) {
                this.flash.vars.permalink = config.permalink;
            }
            
            if (config.name !== undefined) {
                this.flash.vars.name = config.name;
            }
            
            if (config.trackId !== undefined) {
                this.trackId = config.trackId;
            }
            
            if (!this.script) {
                var script = document.createElement("script");
                script.setAttribute("src", "http://cdn.gigya.com/wildfire/js/wfapiv2.js");
                script.setAttribute("type", "text/javascript");
                document.getElementsByTagName("head")[0].appendChild(script);
                this.script = true;
            }
            
            console.error("oh", this.flash.vars);
            
            
            this.flash.vars.trackId = this.trackId;			
	         			
            
            
            this.skin = new Ext.form.RadioGroup({
                itemCls: 'x-check-group-alt',
                hideLabel: true,
                allowBlank: false,
				width:350,
                items: [{
                    items: [{
                        xtype: 'label',
                        text: 'Skin',
                        cls: 'x-form-check-group-label'
                    }, {
                        boxLabel: 'Normal',
                        name: 'skin',      						                
                        id: 'check-normal',
                        inputValue: 'normal',
                        listeners: {
                            'check': J.WizardSong.onSkinChange
                        }
                    }, {
                        boxLabel: 'Round',
                        name: 'skin',						
						checked: true, 
                        id: 'check-round',
                        inputValue: 'round',
                        listeners: {
                            'check': J.WizardSong.onSkinChange
                        }
                    }, {
                        boxLabel: 'Transparent',
                        name: 'skin',
                        id: 'check-transparent',
                        inputValue: 'transparent',
                        listeners: {
                            'check': J.WizardSong.onSkinChange
                        }
                    }, {
                        boxLabel: 'Round Black',
                        name: 'skin',
                        id: 'check-round-black',
                        inputValue: 'round-black',
                        listeners: {
                            'check': J.WizardSong.onSkinChange
                        }
                    }]
                }]
            });
            
            this.colorsEls = [];
            
            this.slide['red'] = new Ext.Slider({
                width: 200,
                id: 'wizard-red',
                minValue: 0,
                maxValue: 255,
                plugins: new Ext.ux.SliderTip(),
                listeners: {
                    'change': function(){
                        J.WizardSong.ColorChange();
                    }
                }
            });
            
            this.slide['green'] = new Ext.Slider({
                width: 200,
                id: 'wizard-green',
                minValue: 0,
                maxValue: 255,
                plugins: new Ext.ux.SliderTip(),
                listeners: {
                    'change': function(){
                        J.WizardSong.ColorChange();
                    }
                }
            });
            
            this.slide['blue'] = new Ext.Slider({
                width: 200,
                id: 'wizard-blue',
                minValue: 0,
                maxValue: 255,
                plugins: new Ext.ux.SliderTip(),
                listeners: {
                    'change': function(){
                        J.WizardSong.ColorChange();
                    }
                }
            });
            
            var cards = [{
                headtitle: 'Choisissez le Look de votre widget',
                xtype: 'form',
                id: 'card-0',
                border: false,
                
                bodyStyle: 'background:none;',
                defaults: {
                    labelStyle: 'font-size:11px',
					style: 'margin-top:2px;'
                },
                items: [{
                    xtype: 'fieldset',
                    height: 70,
                    bodyStyle: 'padding:10px;',
                    title: 'Blog, FaceBook, Myspace, etc ....',
                    items: [{
                        border: false,
                        html: 'Intégrez simplement le lecteur exportable JIWA personnalisé sur votre Blog, Bureau, Facebook, Myspace etc... en quelques clics'
                    }]
                }, {
                    xtype: 'fieldset',
                    height: 250,
                    bodyStyle: 'padding:20px;',
                    title: 'Votre Look',
                    items: [this.skin]
                }]
            }, {
                headtitle: 'Choisissez la Couleur de votre widget',
                id: 'card-1',
				 defaults: {
                    labelStyle: 'font-size:11px',
					style: 'margin-top:2px;'
                },
                border: false,
                items: [{
                    xtype: 'fieldset',
                    height: 210,
                    title: 'Teinte',
                    items: [{
                        xtype: 'colorpicker',
                        title: 'ColorPicker',
                        id: 'panelPicker',
                        listeners: {
                            'pickcolor': function(){
                                 J.WizardSong.ColorChange();
                            }
                        }                    
                    }]
					},
					{   
					xtype: 'fieldset',
                    height: 100,                 
	                layout: 'table',
					title: 'Niveau de Couleur',
	                layoutConfig: {
	                    columns: 3
	                },
                    items: [{
                        width: 150,
                        border: false,
                        items: [{
                            cls: 'wizard-slide-title',
                            html: 'Ajouter du Rouge'
                        },{
                            cls: 'wizard-slide-title',
                            html: 'Ajouter du Vert'
                        },{
                            cls: 'wizard-slide-title',
                            html: 'Ajouter du Bleu'
                        }]
                    },{
						 width: 250,
					 style: 'padding:10px',
                   	 items: [ this.slide['red'], this.slide['green'] ,this.slide['blue']]
                },{
                        style: 'padding:10px',
                        xtype: "button",
                        text: "Valeurs par défauts",
                        listeners: {
                            'click': function(){
                                J.WizardSong.setDefaultRGB();
                            }
                        }
                    
                    }]
                
                }]
				
				}, {
                headtitle: 'Choisissez les Couleurs des Textes de votre widget',
                id: 'card-2',
                border: false,
                bodyStyle: 'background:none;',
                defaults: {
                    labelStyle: 'font-size:11px',
					style: 'margin-top:2px;'
                },
                items: [{
					tag: 'center',
					items: {
						xtype: 'fieldset',
						height: 310,
						title: 'Couleur des textes',
						'layout': 'table',
						layoutConfig: {
							columns: 2
						},
						bodyStyle: 'padding-left:80px',
						items: [{
							width: 280,
							border: false,
							id: 'change-text-color'
						}, {
							border: false,
							style: 'text-align:center',
							items: {
								xtype: "button",
								
								text: "Valeurs par défauts",
								listeners: {
									'click': function(){
										J.WizardSong.setDefaultColors();
									}
								}
							}
						
						}]
					}
				}]
            }, {
                headtitle: 'Copiez le Code ou Intégrez automatiquement le widget  sur votre site',
                id: 'card-3',
                border: false,
                bodyStyle: 'background:none;',
                defaults: {
                    labelStyle: 'font-size:11px',
					style: 'margin-top:2px;'
                },
                items: [{
                    xtype: 'fieldset',
                    height: 500,
                    title: 'Votre Code',
                    items: [{
                        html: '<center><div id="divWildfirePost"></div></center>'
                    }]
                }],
                listeners: {
                    'show': function(){
						J.track('widget','wizard','mono');
                        document.getElementById("code_embed_monotitle").value = document.getElementById("jiwadgetWizard").jsGetCode();
                        var pconf = {
							nowmode:true,
                            includeShareButton: 'false',
                            defaultContent: 'code_embed_monotitle',
                            UIConfig: '<config><display showDesktop="true" showEmail="false" showBookmark="false" showCloseButton="false" postToSidebarChecked="false" networksWithCodeBox=""></display></config>'
                        };
						
						if(T.languageId){
							pconf.lang = 'fr';	
						}
                        Wildfire.initPost('308341', 'divWildfirePost', 450, 350, pconf);
                    }
                }
            }];
            
            var cardPanel = {
                region: 'center',
                layout: 'card',
                style: 'margin-top: 20px;',
                id: 'card-wizard-panel',
                border: false,
                activeItem: 0,
                items: cards
            };
            
            var SouthPanel = {
                region: 'south',
                id: 'widget-wizard-panel',
                height: 85,
                items: [{
                    xtype: 'fieldset',
                    title: 'Widget',
                    style: 'margin-top:2px; padding-top: 10px;',
                    height: 85,
                    html: '<center><div id="jiwadgetWizard"></div></center><textarea id="code_embed_monotitle" style="display:none"></textarea>'
                }]
            };
            
            this.wizard = new Ext.ux.Wiz({
                title: 'Widget MonoTitre',
                resizable: true,
				width:620,
                leftPanel: SouthPanel,
                cardPanelConfig: {
                    defaults: {
                        baseCls: 'x-small-editor',
                        border: false
                    }
                },
                cards: cards
            });
            
            this.wizard.show();
            
            
            swfobject.embedSWF("/res/widget/monotitle.swf", "jiwadgetWizard", "315", "40", "9.0.0", "/res/swf/expressinstall.swf", J.WizardSong.flash.vars, J.WizardSong.flash.params, J.WizardSong.flash.attributes);
            
            this.colors = [{
                colorId: "title",
                value: '',
                name: "Titre du morceau",
                description: ""
            }, {
                colorId: "artist",
                value: '',
                name: "Artiste du morceau",
                description: ""
            }, {
                colorId: "time",
                value: '',
                name: "Temps",
                description: ""
            }, {
                colorId: "volumeBackground",
                value: '',
                name: "Fond de la barre de volume",
                description: ""
            }, {
                colorId: "volume",
                value: '',
                name: "Barre de volume",
                description: ""
            }, {
                colorId: "volumePreview",
                value: '',
                name: "Barre de volume (rollover)",
                description: ""
            }, {
                colorId: "progressBackground",
                value: '',
                name: "Fond de la barre de progression",
                description: ""
            }, {
                colorId: "arrows",
                value: '',
                name: "Flèches de la barre de progression",
                description: ""
            }, {
                colorId: "loadedBar",
                value: '',
                name: "Barre de progression",
                description: ""
            }, {
                colorId: "playedBar",
                value: '',
                name: "Barre de chargement",
                description: ""
            }];
            
            var right = Ext.get('change-text-color');
            
            Ext.each(this.colors, function(color){
            
                var wrapper = right.createChild({
                    cls: "colorSetter"
                });
                
                wrapper.elColorName = wrapper.createChild({
                    cls: "colorName",
                    html: color.name
                });
                
                wrapper.elColorPreview = wrapper.createChild({
                    cls: "colorPreview",
                    style: "background-color:#" + color.value
                });
                
                wrapper.elColorCode = wrapper.createChild({
                    cls: "colorCode",
                    tag: "input",
                    type: "text",
                    value: color.value
                });
                
                wrapper.elColorCode.on("keyup", this.onColorValidated, this, {
                    delay: 200,
                    colorId: color.colorId
                });
                
                wrapper.elColorPreview.on("click", this.onColorMenuSelected, this, {
                    colorId: color.colorId
                });
                
                wrapper.elColorCode.on("change", this.onColorValidated, this, {
                    colorId: color.colorId
                });
                
                this.colorsEls[color.colorId] = wrapper;
            }, this);
            
        },
        
        /*
         * Occurs when a color is selected in the menu.
         *
         * @param colorMenu {Ext.menu.ColorMenu} The color menu
         *
         * @param color {String} The color value (hexadecimal)
         */
        onColorSelected: function(colorMenu, color){
        
            if (typeof color === "string") {
                var wrapper = this.colorsEls[this.currentColorId];
                
                wrapper.elColorCode.dom.value = color;
                
                this.onColorValidated(null, null, {
                    colorId: this.currentColorId
                });
            }
            
        },
        
        onColorValidated: function(ev, target, options){
            var colorId = options.colorId;
            var color = options.color;
            
            var wrapper = this.colorsEls[colorId];
            
            if (options.color) {
                wrapper.elColorCode.dom.value = color = options.color;
            }
            else {
                color = wrapper.elColorCode.dom.value;
            }
            
            wrapper.elColorPreview.setStyle("background-color", "#" + color);
            
            document.getElementById("jiwadgetWizard").jsSetColor(colorId, color);
            
            // this.
        
        },
        
        onColorRevert: function(ev, target, options){
            var colorId = options.colorId;
            var defaultValue = options.defaultValue;
            
            this.onColorValidated(null, null, {
                colorId: colorId,
                color: defaultValue
            });
        },
        
        /*
         * Occurs when the user click on the color menu. Should show the
         * palette.
         */
        onColorMenuSelected: function(ev, target, options){
            var colorId = options.colorId;
            var wrapper = this.colorsEls[colorId];
            this.currentColorId = colorId;
            this.colorMenu = new Ext.menu.ColorMenu({
                handler: this.onColorSelected,
                scope: this
            });
            
            this.colorMenu.show(wrapper.elColorPreview);
        },
        
        /*
         * Occurs when the player is ready. Insert the embed code in the
         * textarea
         */
        onReady: function(){
        
            this.ready = true;            
            
			this.setDefaultRGB();
            this.setDefaultColors();
            
        },
        
        setDefaultColors: function(){
			
			if (Ext.getCmp('check-round-black').getValue()) {
				var DefaultColors = this.normalColors;
			}
			else {
			
				var DefaultColors = document.getElementById("jiwadgetWizard").jsGetColors();
				
			}
			
            this.colors = [{
                colorId: "title",
                value: DefaultColors.title,
                name: "Titre du morceau",
                description: ""
            }, {
                colorId: "artist",
                value: DefaultColors.artist,
                name: "Artiste du morceau",
                description: ""
            }, {
                colorId: "time",
                value: DefaultColors.time,
                name: "Temps",
                description: ""
            }, {
                colorId: "volumeBackground",
                value: DefaultColors.volumeBackground,
                name: "Fond de la barre de volume",
                description: ""
            }, {
                colorId: "volume",
                value: DefaultColors.volume,
                name: "Barre de volume",
                description: ""
            }, {
                colorId: "volumePreview",
                value: DefaultColors.volumePreview,
                name: "Barre de volume (rollover)",
                description: ""
            }, {
                colorId: "progressBackground",
                value: DefaultColors.progressBackground,
                name: "Fond de la barre de progression",
                description: ""
            }, {
                colorId: "arrows",
                value: DefaultColors.arrows,
                name: "Flèches de la barre de progression",
                description: ""
            }, {
                colorId: "loadedBar",
                value: DefaultColors.loadedBar,
                name: "Barre de progression",
                description: ""
            }, {
                colorId: "playedBar",
                value: DefaultColors.playedBar,
                name: "Barre de chargement",
                description: ""
            }];
            
            Ext.each(this.colors, function(color){
            
                J.WizardSong.onColorValidated(null, null, {
                    colorId: color.colorId,
                    color: color.value
                });
            }, this);
            
        },
        
        /*
         * Occurs when a skin checkbox is checked.
         *
         * @param checkbox {Ext.form.Checkbox} The checkbox. @param checked
         * {Boolean} The new checkbox state.
         */
        onSkinChange: function(checkbox, checked){
            if (checked) {
                var skin = checkbox.inputValue;
                if (skin == 'round-black') {
               

			   	document.getElementById("jiwadgetWizard").jsSetSkin('normal');
			   	
			   	this.normalColors = document.getElementById("jiwadgetWizard").jsGetColors();
		
				document.getElementById("jiwadgetWizard").jsSetSkinURL('http://' + location.hostname + '/res/widget/skins/' + skin + '/');
                
				
				}
                else {
                    document.getElementById("jiwadgetWizard").jsSetSkin(skin);
                }
                
            }
        },
        
        ColorChange: function(){
        
            var hexa = Ext.getCmp('panelPicker__iHexa').getValue();
            
            var redOffset = this.slide['red'].getValue();
            var greenOffset = this.slide['green'].getValue();
            var blueOffset = this.slide['blue'].getValue();
            var h = Ext.getCmp('panelPicker__iHue').getValue();
            var s = Ext.getCmp('panelPicker__iSat').getValue();
            var v = Ext.getCmp('panelPicker__iVal').getValue();
			
            document.getElementById("jiwadgetWizard").jsSetSkinColor(h,s,v, redOffset, greenOffset, blueOffset);
            
        },
        setDefaultRGB: function(){
        
            Ext.getCmp('panelPicker__iHexa').setValue('FFFFFF');
            Ext.get('panelPicker__cColor').dom.style.backgroundColor = '#FFFFFF';
            
            this.slide['red'].setValue(0);
            this.slide['green'].setValue(0);
            this.slide['blue'].setValue(0);
			
            var h = Ext.getCmp('panelPicker__iHue').getValue();
            var s = Ext.getCmp('panelPicker__iSat').getValue();
            var v = Ext.getCmp('panelPicker__iVal').getValue();
            
            document.getElementById("jiwadgetWizard").jsSetSkinColor(h,s,v, 0, 0, 0);
            
        }
    };
}();
/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/*
 * Software License Agreement (BSD License)
 * Copyright (c) 2008, Nige "Animal" White
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright notice,
 *       this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright notice,
 *       this list of conditions and the following disclaimer in the documentation
 *       and/or other materials provided with the distribution.
 *     * Neither the name of the original author nor the names of its contributors
 *       may be used to endorse or promote products derived from this software
 *       without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * @class Ext.ux.DDView
 * <p>A DnD-enabled version of {@link Ext.DataView}. Drag/drop is implemented by adding
 * {@link Ext.data.Record}s to the target DDView. If copying is not being performed,
 * the original {@link Ext.data.Record} is removed from the source DDView.</p>
 * @constructor
 * Create a new DDView
 * @param {Object} config The configuration properties.
 */
Ext.ux.DDView = function(config) {
    if (!config.itemSelector) {
        var tpl = config.tpl;
        if (this.classRe.test(tpl)) {
            config.tpl = tpl.replace(this.classRe, 'class=$1x-combo-list-item $2$1');
        }
        else {
            config.tpl = tpl.replace(this.tagRe, '$1 class="x-combo-list-item" $2');
        }
        config.itemSelector = ".x-combo-list-item";
    }
    Ext.ux.DDView.superclass.constructor.call(this, Ext.apply(config, {
        border: false
    }));
};

Ext.extend(Ext.ux.DDView, Ext.DataView, {
    /**
     * @cfg {String/Array} dragGroup The ddgroup name(s) for the View's DragZone (defaults to undefined).
     */
    /**
     * @cfg {String/Array} dropGroup The ddgroup name(s) for the View's DropZone (defaults to undefined).
     */
    /**
     * @cfg {Boolean} copy Causes drag operations to copy nodes rather than move (defaults to false).
     */
    /**
     * @cfg {Boolean} allowCopy Causes ctrl/drag operations to copy nodes rather than move (defaults to false).
     */
    /**
     * @cfg {String} sortDir Sort direction for the view, 'ASC' or 'DESC' (defaults to 'ASC').
     */
    sortDir: 'ASC',

    // private
    isFormField: true,
    classRe: /class=(['"])(.*)\1/,
    tagRe: /(<\w*)(.*?>)/,
    reset: Ext.emptyFn,
    clearInvalid: Ext.form.Field.prototype.clearInvalid,

    // private
    afterRender: function() {
        Ext.ux.DDView.superclass.afterRender.call(this);
        if (this.dragGroup) {
            this.setDraggable(this.dragGroup.split(","));
        }
        if (this.dropGroup) {
            this.setDroppable(this.dropGroup.split(","));
        }
        if (this.deletable) {
            this.setDeletable();
        }
        this.isDirtyFlag = false;
        this.addEvents(
            "drop"
        );
    },

    // private
    validate: function() {
        return true;
    },

    // private
    destroy: function() {
        this.purgeListeners();
        this.getEl().removeAllListeners();
        this.getEl().remove();
        if (this.dragZone) {
            if (this.dragZone.destroy) {
                this.dragZone.destroy();
            }
        }
        if (this.dropZone) {
            if (this.dropZone.destroy) {
                this.dropZone.destroy();
            }
        }
    },

	/**
	 * Allows this class to be an Ext.form.Field so it can be found using {@link Ext.form.BasicForm#findField}.
	 */
    getName: function() {
        return this.name;
    },

	/**
	 * Loads the View from a JSON string representing the Records to put into the Store.
     * @param {String} value The JSON string
	 */
    setValue: function(v) {
        if (!this.store) {
            throw "DDView.setValue(). DDView must be constructed with a valid Store";
        }
        var data = {};
        data[this.store.reader.meta.root] = v ? [].concat(v) : [];
        this.store.proxy = new Ext.data.MemoryProxy(data);
        this.store.load();
    },

	/**
	 * Returns the view's data value as a list of ids.
     * @return {String} A parenthesised list of the ids of the Records in the View, e.g. (1,3,8).
	 */
    getValue: function() {
        var result = '(';
        this.store.each(function(rec) {
            result += rec.id + ',';
        });
        return result.substr(0, result.length - 1) + ')';
    },

    getIds: function() {
        var i = 0, result = new Array(this.store.getCount());
        this.store.each(function(rec) {
            result[i++] = rec.id;
        });
        return result;
    },

    /**
     * Returns true if the view's data has changed, else false.
     * @return {Boolean}
     */
    isDirty: function() {
        return this.isDirtyFlag;
    },

	/**
	 * Part of the Ext.dd.DropZone interface. If no target node is found, the
	 * whole Element becomes the target, and this causes the drop gesture to append.
	 */
    getTargetFromEvent : function(e) {
        var target = e.getTarget();
        while ((target !== null) && (target.parentNode != this.el.dom)) {
            target = target.parentNode;
        }
        if (!target) {
            target = this.el.dom.lastChild || this.el.dom;
        }
        return target;
    },

	/**
	 * Create the drag data which consists of an object which has the property "ddel" as
	 * the drag proxy element.
	 */
    getDragData : function(e) {
        var target = this.findItemFromChild(e.getTarget());
        if(target) {
            if (!this.isSelected(target)) {
                delete this.ignoreNextClick;
                this.onItemClick(target, this.indexOf(target), e);
                this.ignoreNextClick = true;
            }
            var dragData = {
                sourceView: this,
                viewNodes: [],
                records: [],
                copy: this.copy || (this.allowCopy && e.ctrlKey)
            };
            if (this.getSelectionCount() == 1) {
                var i = this.getSelectedIndexes()[0];
                var n = this.getNode(i);
                dragData.viewNodes.push(dragData.ddel = n);
                dragData.records.push(this.store.getAt(i));
                dragData.repairXY = Ext.fly(n).getXY();
            } else {
                dragData.ddel = document.createElement('div');
                dragData.ddel.className = 'multi-proxy';
                this.collectSelection(dragData);
            }
            return dragData;
        }
        return false;
    },

    // override the default repairXY.
    getRepairXY : function(e){
        return this.dragData.repairXY;
    },

	// private
    collectSelection: function(data) {
        data.repairXY = Ext.fly(this.getSelectedNodes()[0]).getXY();
        if (this.preserveSelectionOrder === true) {
            Ext.each(this.getSelectedIndexes(), function(i) {
                var n = this.getNode(i);
                var dragNode = n.cloneNode(true);
                dragNode.id = Ext.id();
                data.ddel.appendChild(dragNode);
                data.records.push(this.store.getAt(i));
                data.viewNodes.push(n);
            }, this);
        } else {
            var i = 0;
            this.store.each(function(rec){
                if (this.isSelected(i)) {
                    var n = this.getNode(i);
                    var dragNode = n.cloneNode(true);
                    dragNode.id = Ext.id();
                    data.ddel.appendChild(dragNode);
                    data.records.push(this.store.getAt(i));
                    data.viewNodes.push(n);
                }
                i++;
            }, this);
        }
    },

	/**
	 * Specify to which ddGroup items in this DDView may be dragged.
     * @param {String} ddGroup The DD group name to assign this view to.
	 */
    setDraggable: function(ddGroup) {
        if (ddGroup instanceof Array) {
            Ext.each(ddGroup, this.setDraggable, this);
            return;
        }
        if (this.dragZone) {
            this.dragZone.addToGroup(ddGroup);
        } else {
            this.dragZone = new Ext.dd.DragZone(this.getEl(), {
                containerScroll: true,
                ddGroup: ddGroup
            });
            // Draggability implies selection. DragZone's mousedown selects the element.
            if (!this.multiSelect) { this.singleSelect = true; }

            // Wire the DragZone's handlers up to methods in *this*
            this.dragZone.getDragData = this.getDragData.createDelegate(this);
            this.dragZone.getRepairXY = this.getRepairXY;
            this.dragZone.onEndDrag = this.onEndDrag;
        }
    },

	/**
	 * Specify from which ddGroup this DDView accepts drops.
     * @param {String} ddGroup The DD group name from which to accept drops.
	 */
    setDroppable: function(ddGroup) {
        if (ddGroup instanceof Array) {
            Ext.each(ddGroup, this.setDroppable, this);
            return;
        }
        if (this.dropZone) {
            this.dropZone.addToGroup(ddGroup);
        } else {
            this.dropZone = new Ext.dd.DropZone(this.getEl(), {
                owningView: this,
                containerScroll: true,
                ddGroup: ddGroup
            });

            // Wire the DropZone's handlers up to methods in *this*
            this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
            this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
            this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
            this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
            this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
        }
    },

	// private
    getDropPoint : function(e, n, dd){
        if (n == this.el.dom) { return "above"; }
        var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
        var c = t + (b - t) / 2;
        var y = Ext.lib.Event.getPageY(e);
        if(y <= c) {
            return "above";
        }else{
            return "below";
        }
    },

    // private
    isValidDropPoint: function(pt, n, data) {
        if (!data.viewNodes || (data.viewNodes.length != 1)) {
            return true;
        }
        var d = data.viewNodes[0];
        if (d == n) {
            return false;
        }
        if ((pt == "below") && (n.nextSibling == d)) {
            return false;
        }
        if ((pt == "above") && (n.previousSibling == d)) {
            return false;
        }
        return true;
    },

    // private
    onNodeEnter : function(n, dd, e, data){
        if (this.highlightColor && (data.sourceView != this)) {
            this.el.highlight(this.highlightColor);
        }
        return false;
    },

    // private
    onNodeOver : function(n, dd, e, data){
        var dragElClass = this.dropNotAllowed;
        var pt = this.getDropPoint(e, n, dd);
        if (this.isValidDropPoint(pt, n, data)) {
            if (this.appendOnly || this.sortField) {
                return "x-tree-drop-ok-below";
            }

            // set the insert point style on the target node
            if (pt) {
                var targetElClass;
                if (pt == "above"){
                    dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
                    targetElClass = "x-view-drag-insert-above";
                } else {
                    dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
                    targetElClass = "x-view-drag-insert-below";
                }
                if (this.lastInsertClass != targetElClass){
                    Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
                    this.lastInsertClass = targetElClass;
                }
            }
        }
        return dragElClass;
    },

    // private
    onNodeOut : function(n, dd, e, data){
        this.removeDropIndicators(n);
    },

    // private
    onNodeDrop : function(n, dd, e, data){
        if (this.fireEvent("drop", this, n, dd, e, data) === false) {
            return false;
        }
        var pt = this.getDropPoint(e, n, dd);
        var insertAt = (this.appendOnly || (n == this.el.dom)) ? this.store.getCount() : n.viewIndex;
        if (pt == "below") {
            insertAt++;
        }

        // Validate if dragging within a DDView
        if (data.sourceView == this) {
            // If the first element to be inserted below is the target node, remove it
            if (pt == "below") {
                if (data.viewNodes[0] == n) {
                    data.viewNodes.shift();
                }
            } else {  // If the last element to be inserted above is the target node, remove it
                if (data.viewNodes[data.viewNodes.length - 1] == n) {
                    data.viewNodes.pop();
                }
            }

            // Nothing to drop...
            if (!data.viewNodes.length) {
                return false;
            }

            // If we are moving DOWN, then because a store.remove() takes place first,
            // the insertAt must be decremented.
            if (insertAt > this.store.indexOf(data.records[0])) {
                insertAt--;
            }
        }

        // Dragging from a Tree. Use the Tree's recordFromNode function.
        if (data.node instanceof Ext.tree.TreeNode) {
            var r = data.node.getOwnerTree().recordFromNode(data.node);
            if (r) {
                data.records = [ r ];
            }
        }

        if (!data.records) {
            alert("Programming problem. Drag data contained no Records");
            return false;
        }

        for (var i = 0; i < data.records.length; i++) {
            var r = data.records[i];
            var dup = this.store.getById(r.id);
            if (dup && (dd != this.dragZone)) {
                if(!this.allowDup && !this.allowTrash){
                    Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
                    return true
                }
                var x=new Ext.data.Record();
                r.id=x.id;
                delete x;
            }
            if (data.copy) {
                this.store.insert(insertAt++, r.copy());
            } else {
                if (data.sourceView) {
                    data.sourceView.isDirtyFlag = true;
                    data.sourceView.store.remove(r);
                }
                if(!this.allowTrash)this.store.insert(insertAt++, r);
            }
            if(this.sortField){
                this.store.sort(this.sortField, this.sortDir);
            }
            this.isDirtyFlag = true;
        }
        this.dragZone.cachedTarget = null;
        return true;
    },

    // private
    onEndDrag: function(data, e) {
        var d = Ext.get(this.dragData.ddel);
        if (d && d.hasClass("multi-proxy")) {
            d.remove();
            //delete this.dragData.ddel;
        }
    },

    // private
    removeDropIndicators : function(n){
        if(n){
            Ext.fly(n).removeClass([
                "x-view-drag-insert-above",
                "x-view-drag-insert-left",
                "x-view-drag-insert-right",
                "x-view-drag-insert-below"]);
            this.lastInsertClass = "_noclass";
        }
    },

	/**
	 * Add a delete option to the DDView's context menu.
	 * @param {String} imageUrl The URL of the "delete" icon image.
	 */
    setDeletable: function(imageUrl) {
        if (!this.singleSelect && !this.multiSelect) {
            this.singleSelect = true;
        }
        var c = this.getContextMenu();
        this.contextMenu.on("itemclick", function(item) {
            switch (item.id) {
                case "delete":
                    this.remove(this.getSelectedIndexes());
                    break;
            }
        }, this);
        this.contextMenu.add({
            icon: imageUrl || AU.resolveUrl("/images/delete.gif"),
            id: "delete",
            text: AU.getMessage("deleteItem")
        });
    },

	/**
	 * Return the context menu for this DDView.
     * @return {Ext.menu.Menu} The context menu
	 */
    getContextMenu: function() {
        if (!this.contextMenu) {
            // Create the View's context menu
            this.contextMenu = new Ext.menu.Menu({
                id: this.id + "-contextmenu"
            });
            this.el.on("contextmenu", this.showContextMenu, this);
        }
        return this.contextMenu;
    },

    /**
     * Disables the view's context menu.
     */
    disableContextMenu: function() {
        if (this.contextMenu) {
            this.el.un("contextmenu", this.showContextMenu, this);
        }
    },

    // private
    showContextMenu: function(e, item) {
        item = this.findItemFromChild(e.getTarget());
        if (item) {
            e.stopEvent();
            this.select(this.getNode(item), this.multiSelect && e.ctrlKey, true);
            this.contextMenu.showAt(e.getXY());
        }
    },

	/**
	 * Remove {@link Ext.data.Record}s at the specified indices.
	 * @param {Array/Number} selectedIndices The index (or Array of indices) of Records to remove.
	 */
    remove: function(selectedIndices) {
        selectedIndices = [].concat(selectedIndices);
        for (var i = 0; i < selectedIndices.length; i++) {
            var rec = this.store.getAt(selectedIndices[i]);
            this.store.remove(rec);
        }
    },

	/**
	 * Double click fires the {@link #dblclick} event. Additionally, if this DDView is draggable, and there is only one other
	 * related DropZone that is in another DDView, it drops the selected node on that DDView.
	 */
    onDblClick : function(e){
        var item = this.findItemFromChild(e.getTarget());
        if(item){
            if (this.fireEvent("dblclick", this, this.indexOf(item), item, e) === false) {
                return false;
            }
            if (this.dragGroup) {
                var targets = Ext.dd.DragDropMgr.getRelated(this.dragZone, true);

                // Remove instances of this View's DropZone
                while (targets.indexOf(this.dropZone) !== -1) {
                    targets.remove(this.dropZone);
                }

                // If there's only one other DropZone, and it is owned by a DDView, then drop it in
                if ((targets.length == 1) && (targets[0].owningView)) {
                    this.dragZone.cachedTarget = null;
                    var el = Ext.get(targets[0].getEl());
                    var box = el.getBox(true);
                    targets[0].onNodeDrop(el.dom, {
                        target: el.dom,
                        xy: [box.x, box.y + box.height - 1]
                    }, null, this.getDragData(e));
                }
            }
        }
    },

    // private
    onItemClick : function(item, index, e){
        // The DragZone's mousedown->getDragData already handled selection
        if (this.ignoreNextClick) {
            delete this.ignoreNextClick;
            return;
        }

        if(this.fireEvent("beforeclick", this, index, item, e) === false){
            return false;
        }
        if(this.multiSelect || this.singleSelect){
            if(this.multiSelect && e.shiftKey && this.lastSelection){
                this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
            } else if (this.isSelected(item) && e.ctrlKey) {
                this.deselect(item);
            }else{
                this.deselect(item);
                this.select(item, this.multiSelect && e.ctrlKey);
                this.lastSelection = item;
            }
            e.preventDefault();
        }
        return true;
    }
});
	/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 this
 * http://extjs.com/license
 */
Ext.override(Ext.Container, {

    applyState: function(state, config){
    
        this.stateful = false;
        
        for (var i = 0; i < state.length; i++) {
        
            var col = this.items.items[i];
            
            while (col.items && col.items.length > 0) 
                col.remove(col.items.items[0]);
            
            for (var j = 0; j < state[i].length; j++) 
            
                col.add(state[i][j]);
            
        }
       this.stateful = true;
        
    },
    getConfig: function(){
       if(this.data){
		   	if(this.data.page){
				this.data.page=[];
			}
	   }
	var state =Ext.applyIf({
								xtype: this.xtype,
								data: this.data,
								width: this.width,
								columnWidth: this.columnWidth
							}, this.initialConfig);
	
		
		if (this.items) {
			
			
			if (this.items.items) {
				state.items =[];
				
				for (var i = 0; i < this.items.items.length; i++) {
				
					var col = this.items.items[i];
					
					if (col) {
					
						state.items[i] = col.getConfig();
						
					}
					
				}
				
				if(state.items.length ==0){
					state.items =null;
				}
			}
		}
		
		return state;
    }
});



Ext.ux.Portal = Ext.extend(Ext.Panel, {
	anchor:'100%',
    draggable: false,
    layout: 'column',
    autoScroll: false,
	 header:false ,
    cls: 'x-portal',
    defaultType: 'portalcolumn',
    // configurables
    // }}}
    initComponent: function(){
        Ext.ux.Portal.superclass.initComponent.call(this);
        this.addEvents({
            validatedrop: true,
            beforedragover: true,
            dragover: true,
            beforedrop: true,
            drop: true
        });
    },
    
    initEvents: function(){
        Ext.ux.Portal.superclass.initEvents.call(this);
        this.dd = new Ext.ux.Portal.DropZone(this, this.dropConfig);
    },
    
    beforeDestroy: function(){
        if (this.dd) {
            this.dd.unreg();
        }
        Ext.ux.Portal.superclass.beforeDestroy.call(this);
    }
    
});

Ext.reg('portal', Ext.ux.Portal);

Ext.ux.Portal.DropZone = function(portal, cfg){
    this.portal = portal;
    Ext.dd.ScrollManager.register(portal.body);
    Ext.ux.Portal.DropZone.superclass.constructor.call(this, portal.bwrap.dom, cfg);
    portal.body.ddScrollConfig = this.ddScrollConfig;
};

Ext.extend(Ext.ux.Portal.DropZone, Ext.dd.DropTarget, {
    ddScrollConfig: {
        vthresh: 50,
        hthresh: -1,
        animate: true,
        increment: 200
    },
    createEvent: function(dd, e, data, col, c, pos){
        return {
            portal: this.portal,
            panel: data.panel,
            columnIndex: col,
            column: c,
            position: pos,
            data: data,
            source: dd,
            rawEvent: e,
            status: this.dropAllowed
        };
    },
    
    notifyOver: function(dd, e, data){
        var xy = e.getXY(), portal = this.portal, px = dd.proxy;
        
        // case column widths
        if (!this.grid) {
            this.grid = this.getGrid();
        }
        
        // handle case scroll where scrollbars appear during drag
        var cw = portal.body.dom.clientWidth;
        if (!this.lastCW) {
            this.lastCW = cw;
        }
        else 
            if (this.lastCW != cw) {
                this.lastCW = cw;
                portal.doLayout();
                this.grid = this.getGrid();
            }
        
        // determine column
        var col = 0, xs = this.grid.columnX, cmatch = false;
        for (var len = xs.length; col < len; col++) {
            if (xy[0] < (xs[col].x + xs[col].w)) {
                cmatch = true;
                break;
            }
        }
        // no match, fix last index
        if (!cmatch) {
            col--;
        }
        
        // find insert position
        var p, match = false, pos = 0, c = portal.items.itemAt(col), items = c.items.items, overSelf = false;
        
        for (var len = items.length; pos < len; pos++) {
            p = items[pos];
            var h = p.el.getHeight();
            if (h === 0) {
                overSelf = true;
            }
            else 
                if ((p.el.getY() + (h / 2)) > xy[1]) {
                    match = true;
                    break;
                }
        }
        
        pos = (match && p ? pos : c.items.getCount()) + (overSelf ? -1 : 0);
        var overEvent = this.createEvent(dd, e, data, col, c, pos);
        
        if (portal.fireEvent('validatedrop', overEvent) !== false &&
        portal.fireEvent('beforedragover', overEvent) !== false) {
        
            // make sure proxy width is fluid
            px.getProxy().setWidth('auto');
            
            if (p) {
                px.moveProxy(p.el.dom.parentNode, match ? p.el.dom : null);
            }
            else {
                px.moveProxy(c.el.dom, null);
            }
            
            this.lastPos = {
                c: c,
                col: col,
                p: overSelf || (match && p) ? pos : false
            };
            this.scrollPos = portal.body.getScroll();
            
            portal.fireEvent('dragover', overEvent);
            
            return overEvent.status;
			
        }else {
            return overEvent.status;
        }
        
    },
    
    notifyOut: function(){
        delete this.grid;
    },
    notifyDrop: function(dd, e, data){
        delete this.grid;
        if (!this.lastPos) {
            return;
        }
        var c = this.lastPos.c, col = this.lastPos.col, pos = this.lastPos.p;
        
        var dropEvent = this.createEvent(dd, e, data, col, c, pos !== false ? pos : c.items.getCount());
        
        if (this.portal.fireEvent('validatedrop', dropEvent) !== false &&
        this.portal.fireEvent('beforedrop', dropEvent) !== false) {
        
            dd.proxy.getProxy().remove();
            dd.panel.el.dom.parentNode.removeChild(dd.panel.el.dom);
            
            if (pos !== false) {
                if (c == dd.panel.ownerCt && (c.items.items.indexOf(dd.panel) <= pos)) {
                    pos++;
                }
                c.insert(pos, dd.panel);
            }
            else {
                c.add(dd.panel);
            }
            
            c.doLayout();
            
            this.portal.fireEvent('drop', dropEvent);
            
            // scroll position is lost on drop, fix it
            var st = this.scrollPos.top;
            if (st) {
                var d = this.portal.body.dom;
                setTimeout(function(){
                    d.scrollTop = st;
                }, 10);
            }
            
        }
        delete this.lastPos;
    },
    
    // internal cache of body and column coords
    getGrid: function(){
        var box = this.portal.bwrap.getBox();
        box.columnX = [];
        this.portal.items.each(function(c){
            box.columnX.push({
                x: c.el.getX(),
                w: c.el.getWidth()
            });
        });
        return box;
    },
    // unregister the dropzone from ScrollManager
    unreg: function(){
        //Ext.dd.ScrollManager.unregister(this.portal.body);
        Ext.ux.Portal.DropZone.superclass.unreg.call(this);
    }
});

Ext.reg('portal', Ext.ux.Portal);

Ext.ux.MainPortal = Ext.extend(Ext.Panel, {
	anchor:'100%',
    draggable: false,
    layout: 'column',
    autoScroll: true,
    draggable: false,
    initComponent: function(arguments){
    if (!J.fc.preview) {
        Ext.apply(this, {
            tbar: [ {text :'Fichier',
			menu :[{
                text: "Enregistrer",
                handler: function(){
                    J.fc.controller	.model.reqSave();
                    }
            	}, {
					text: "Enregistrer Sous",
					handler: function(){
						J.fc.controller.create();
					}
				}, {
                text: "Appliquer sur la Home",
                handler: function(){
                    J.fc.controller.model.reqSelect();
                }
            
            }]},
			
			  {text :'Affichage',
			menu :[{
                text: "Vue Normal",
                handler: function(){
					J.fc.preview=false;
					J.fc.controller.view.refresh();
                }
            }, {
                text: "Preview",
                handler: function(){
					J.fc.preview=true;
					J.fc.controller.view.refresh();
                }
            }, {
                text: "Recharger les données",
                handler: function(){
					J.fc.controller.model.reqReload();
                }
           }]},{
                text: "Ajouter 1 block",
                handler: function(){
                    J.fc.controller.addMainRow(1);
                }
            },{
                text: "Ajouter 2 block ",
                handler: function(){
                   J.fc.controller.addMainRow(2);
                }
            },'->',{
                text: "Ajouter un block",
                handler: function(){
                   J.fc.controller.addMainBlock();
                }
            }]
        });
		
	}else{
		Ext.apply(this, {
            title:'',
			border:false,
			header:false 
        });
	}

        Ext.ux.MainPortal.superclass.initComponent.apply(this);
        
    }
    
});
Ext.reg('mainportal', Ext.ux.MainPortal);

Ext.ux.PortalColumn = Ext.extend(Ext.Container, {
    layout: 'anchor',
    draggable: false,
    autoEl: 'div',
	 header:false ,
    defaultType: 'dataportlet',
    cls: 'x-portal-column'
});
Ext.reg('portalcolumn', Ext.ux.PortalColumn);

Ext.ux.RowPortlet = Ext.extend(Ext.Panel, {
    frame: true,
    collapsible: false,
    draggable: false,
	header:false,
	setColunm:function(e, target, portal,nb){
		
		var config = [];
		for(i=0;i<nb;i++){
			
		var item ={xtype: 'portalcolumn',
						columnWidth : 1/nb,
						items :{
						title: 'data',
						xtype: 'dataportlet'
					}
			};
			config.push(item);
		}
		
	  	portal.insert(0,{xtype: 'portal',items:config});
				
		portal.doLayout();
		
	},    initComponent: function(){
    	var index = this.index;
		
		 if (!J.fc.preview) {
		 	Ext.apply(this, {
		 		draggable: true,
		 		header: true,
		 		tools: [{
		 			id: 'close',
		 			qtip: 'Supprimer',
		 			handler: function(e, target, panel){
		 				panel.ownerCt.remove(panel, true);
		 			}
		 		}]
		 	});
		 	
		 }
		 else {
		 
		 	Ext.apply(this, {
		 		tools: null,
		 		title: '',
		 		border: false,
		 		header: false
		 	});
		 	
		 }
		
        Ext.ux.RowPortlet.superclass.initComponent.apply(this);
        
    },
	defaultType: 'dataportlet'
});
Ext.reg('rowportlet', Ext.ux.RowPortlet);

Ext.ux.ColumnPortlet = Ext.extend(Ext.ux.RowPortlet, {
	defaultType: 'portal',
	draggable:false,
	header:false 
});
Ext.reg('columportlet', Ext.ux.ColumnPortlet);



Ext.ux.AdPortlet = Ext.extend(Ext.Panel, {
	frame: true,
    collapsible: false,
	anchor:'100%',
    draggable: false,
	data: {},
	refreshData:function(){
		
		if(this.data.title){
			this.setTitle(this.data.title);
		}
	
		if(this.data.color){
			this.addClass(this.data.color);
		}

		
	},
	html:"<iframe width='300' scrolling='no' height='250' frameborder='0' align='top' marginheight='0' marginwidth='0' src='/res/html/ads/FR-HP-300x250.html?v=2' name='ajaxAd2' id='ajaxAd2'/>",
	initComponent: function(arguments){
  
  		if (this.data.format) {
			this.tpl = J.Template.home(this.data.format);
    	}
		 
		this.refreshData(this);
		
		Ext.ux.AdPortlet.superclass.initComponent.apply(this);
		
        // call parent
     
    },
    cls: 'x-portlet'
});
Ext.reg('adportlet', Ext.ux.AdPortlet);


Ext.ux.DataPortlet = Ext.extend(Ext.ux.AdPortlet, {
    frame: true,
    collapsible: false,
	anchor:'100%',
    draggable: false,
	cls: 'x-portlet',
	data: {},
	html:'',
    onRender: function(ct, position) {
        Ext.ux.DataPortlet.superclass.onRender.call(this, ct, position);
        if (this.data.page) {
            this.update(this.data.page);
        }
    },
    update: function(data) {
        if(this.tpl){
			this.tpl.overwrite(this.body, data);
		}
    },
	refreshData:function(){
		
		if(this.data.title){
			this.setTitle(this.data.title);
		}
	
		if(this.data.icones){
			if(this.data.icones != "-"){
				this.setIconClass('icones ico-'+this.data.icones);
			}
		}
		
		if (this.data.format == "6") {
			this.data.maxItems = 1;			
		}
		
		if(this.data.height){
			var height = parseInt(this.data.height);
			if(height>0){
				this.setHeight(height);
			}
			
		}
		
		 if(this.tpl){
		 	if (this.data.page) {
				if (this.body) {
					this.tpl.overwrite(this.body, this.data.page);
				}
			}
		}
		
	},
    initComponent: function(arguments){
    
       if (!J.fc.preview) {
		   	Ext.apply(this, {
				 draggable: true,
				tools: [{
					id: 'gear',
					qtip: 'Editer cette box',
					handler: function(e, target, panel){
						J.fc.controller.popupEditBox(panel);
					}
				}, {
					id: 'close',
					qtip: 'Supprimer',
					handler: function(e, target, panel){
						panel.ownerCt.remove(panel, true);
					}
				}]
			}); // end of apply
			
		}
		
    
		if (this.data.format) {
			this.tpl = J.Template.home(this.data.format);
    	 }
		 
	
	
		this.refreshData(this);
		
        // call parent
        Ext.ux.DataPortlet.superclass.initComponent.apply(this);
		
    }
});
Ext.reg('dataportlet', Ext.ux.DataPortlet);/**
 * @author admin
 */
J.render = function(){

    return {
        isDownloadable: function(trackId){
            var infoDate = tr('track_date_' + trackId);
            if (!infoDate.begin) {
                console.log(trackId);
                return result = {
                    granted: true
                };
            }
            var dateToday = new Date();
            var dateBegin = new Date(infoDate.begin);
            var dateEnd = new Date(infoDate.end);
            var result = {
                granted: (Date.parse(dateToday) < Date.parse(dateEnd) && Date.parse(dateToday) > Date.parse(dateBegin))
            };
            return result;
        },
        getDateDispoForDownload: function(trackId){
            var infoDate = tr('track_date_' + trackId);
            var dateToday = new Date();
            var dateBegin = new Date(infoDate.begin);
            var dateEnd = new Date(infoDate.end);
            if (Date.parse(dateToday) > Date.parse(dateEnd)) {
                return tr('dl_not_dispo_too_late') + " " + dateEnd.format(tr('formatDate'));
            }
            else {
                return tr('dl_not_dispo_not_more') + " " + dateBegin.format(tr('formatDate'));
            }
        },
        escape: function(value){
            return String.escape(value);
        },
        reduce: function(value, len){
			var result =value;
            if (len == undefined && value.length > 40) {
                result =  value.substr(0, 40 - 6) + "..." + value.substr(value.length - 3, value.length);
            }else if (value && value.length > len) {
                result = value.substr(0, len - 6) + "..." + value.substr(value.length - 3, value.length);
            }
            return result;
        },
        reduce2: function(value){
			var result =value;
            if (value.length > 90) {
                result = value.substr(0, 90 - 6) + "..." + value.substr(value.length - 3, value.length);
            }
            
			return result;
            
        },
        reduceTitleTrackOnDownloadOP: function(value){
            if (value.length > 35) {
                return value.substr(0, 35 - 11) + "..." + value.substr(value.length - 8, value.length);
            }
            else {
                return value;
            }
        },
        cardTopText: function(value){
            if (value.length > 30) {
                return Ext.util.Format.ellipsis(value, 28);
            }
            else {
                return value;
            }
        },
        playButtonRenderer: function(){
            return "<div class='row'><div class='icon play'></div></div>";
        },
        enqueueButtonRenderer: function(){
            return "<div class='icon row add'></div>";
        },
        songNameRenderer: function(value, meta, record){
			
			var extrait = "";
			
			if (record.data.restricted == 1){
				extrait = "[30s] ";
			}
            return String.format('<span class="songName">{0}{1}</span>', extrait,J.render.reduce(value, 35));
        },
        popularityRenderer: function(value){
        
            if (value == null || value == "") {
                value = 0;
            }
            
            var max = 1000000;
            var width = parseInt(value) / max;
            if (width < 0) {
                width = 0;
            }
            else 
                if (width > 1) {
                    width = 1;
                }
            width = 100 * width;
            
            return "<div class='popularity-bg'><div class='popularity-value' style='width: " + width + "%'></div></div>";
        },
        songPopularityRenderer: function(value){
        
            if (value == null || value == "") {
                value = 0;
            }
            var max = 1000000;
            var width = value / max;
            if (width < 0) {
                width = 0;
            }
            else 
                if (width > 1) {
                    width = 1;
                }
            width = 100 * width;
            return "<div class='popularity-bg'><div class='popularity-value' style='width: " + width + "%'></div></div>";
        },
        
        womanPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/f{0}.jpg', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/f{0}.jpg', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/f{0}.jpg', "default"), 50);
        },
        manPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/m{0}.jpg', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/m{0}.jpg', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/m{0}.jpg', "default"), 50);
        },
        albumPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/album/80/{0}.jpg', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/album/50/{0}.jpg', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/album/80/{0}.jpg', "default"), 50);
            
        }, 
		artistPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg', "default"), 50);
            
        },
        albumPictureDownloadRenderer: function(value){
            return J.render.cadre(String.format(J.MEDIAPATH + '/album/50/{0}.jpg', value), 50);
        },
        itemPictureRenderer: function(value){
            return J.render.cadre(value, 50);
        },
		smallRadioPicture: function(value){
			return J.render.cadre(String.format(J.MEDIAPATH + '/radio/50/{0}.jpg', value), 50);
		},
		bigRadioPicture: function(value){
			return J.render.cadre(String.format(J.MEDIAPATH + '/radio/80/{0}.jpg', value), 80);
		},
        itemBigPictureRenderer: function(value){
            return J.render.cadre(value, 80);
        },
        albumNameRenderer: function(value, meta, record){
            var data = record.data;
            
            if (record.data.nbSongs != "" && record.data.nbSongs >= 0) {
                return String.format('<span class="albumName">{0}</span><span class="nbSong"> ( ' + record.data.nbSongs + ' ' + tr('tracks') + ' )</span>', value);
            }
            else {
                return String.format('<span class="albumName">{0}</span><span class="nbSong">', value);
            }
        },
        artistNameRenderer: function(value){
            return String.format('<span class="artistName">{0}</span>', value);
        },
        newsRenderer: function(value){
            return String.format('<span class="newsName">{0}</span>', value);
        },
        artistPictureRenderer: function(value, meta, record){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg"', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg"', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/artist/50/{0}.jpg', "default"), 50);
        },
        
        newsPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture && record.data.hasPicture == 1) {
                    return String.format(J.MEDIAPATH + '/news/100/{0}.jpg', value), 80;
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture && meta.hasPicture == 1) {
                        return String.format(J.MEDIAPATH + '/news/100/{0}.jpg', value), 80;
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/news/100/{0}.jpg', "default"), 80);
        },
        newsEditoPictureRenderer: function(value, meta, record, row, column, store){
            return J.render.cadre(String.format(J.MEDIAPATH + '/news/131/{0}.jpg', value), 80);
        },
        playlistPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
                    return J.render.cadre(String.format(J.MEDIAPATH + '/playlist/50/{0}.jpg', value), 50);
                }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                        return J.render.cadre(String.format(J.MEDIAPATH + '/playlist/50/{0}.jpg', value), 50);
                    }
                }
            return J.render.cadre(String.format(J.MEDIAPATH + '/playlist/50/{0}.jpg', "default"), 50);
            
        },
        playlistNameRenderer: function(value, meta, record){
            var data = record.data;
            if (record.data.nbSongs != "" && record.data.nbSongs >= 0) {
                return String.format('<span class="playlistName">{0}</span><span class="nbSong"> ( ' + record.data.nbSongs + ' ' + tr('tracks') + ' )</span>', value);
            }
            else {
                return String.format('<span class="playlistName">{0}</span><span class="nbSong">', value);
            }
        },
        getNewsPicture: function(value){
            return String.format(J.MEDIAPATH + '/news/131/{0}.jpg', value);
        },
        getThreadPicture: function(value){
            return String.format(J.MEDIAPATH + '/news/80/{0}.jpg', value);
        },
        userNameRenderer: function(value){
            return String.format('<span class="jListGrid-userName">{0}</span>', value);
        },
        userPictureRenderer: function(value, meta, record, row, column, store){
            if (record) {
                if (record.data.hasPicture) {
               return J.render.cadre(J.MEDIAPATH + '/user/50/' + record.data.userPicture + '.jpg', 50);
			    }
            }
            else 
                if (meta) {
                    if (meta.hasPicture) {
                   return J.render.cadre(J.MEDIAPATH + '/user/50/' + meta.data.userPicture + '.jpg', 50); }
                }
            
            
        },
        pictureRenderer: function(value, meta, record, row, column, store){
            if (value) {
                return J.render.cadre(String.format(J.MEDIAPATH + '/user/50/{0}.jpg', value), 50);
            
            }
			
			if (record) {
				return J.render.cadre(J.MEDIAPATH + '/user/50/' + record.data.userPicture + '.jpg', 50);
			}
        },
        userPreviewRenderer: function(value, meta, record, row, column, store){
            return '<a href="#user/' + record.data.userId + '"><div class="jListGrid-userPreviewPicture">' +
            J.render.cadre(J.MEDIAPATH + '/user/50/' + record.data.userPicture + '.jpg', 50) +
            "</div>" +
            '<div class="jListGrid-userPreviewName">' +
            record.data.userName +
            '</div></a>';
        },
        recipicentPreviewRenderer: function(value, meta, record, row, column, store){
            return String.format('<span class="jListGrid-userName">{0}</span>', value);
        },
        subjectPreviewRenderer: function(value, meta, record, row, column, store){
            return '<div class="jListGrid-subject">' + value +
            '</div">' +
            '<div class="jListGrid-body">' +
            J.render.reduce(record.data.bodyPreview, 200) +
            '</div>';
        },
        flagRenderer: function(value){
            if (value) {
                return '<div class="read-mail"></div>';
            }
            else {
                return '<div class="noread-mail"></div>';
            }
        },
        progressionRenderer: function(value){
            if (value == null) {
                return '<i style="color:black;text-align:center;">' + tr("topSong_new") + '</i>';
            }
            else 
                if (value > 0) {
                    return '<i style="color:green;text-align:center;">' + '+' + value + '</i>';
                }
                else 
                    if (value == 0) {
                        return '<i style="color:black;text-align:center;">=</i>';
                    }
                    else 
                        if (value < 0) {
                            return '<i style="color:red;text-align:center;">' + value + '</i>';
                        }
        },
        actionsRenderer: function(value, meta, record, row, column, store){
            if (record.data.trackId && record.data.restricted !=2) {
                return '<div class="row">' +
                '<div class="icon play" ext:qtip="' +
                tr('trackGrid_tip_play') +
                '"></div>' +
                '<div class="icon enqueue" ext:qtip="' +
                tr('trackGrid_tip_enqueue') +
                '">' +
                '</div>' +
                '<div class="icon add" ext:qtip="' +
                tr('trackGrid_tip_add') +
                '">' +
                '</div>' +
                '</div>';
            }
            else {
                return '';
            }
        },
        cadre: function(image, width){
            return '<div class="jGrid-illustration-wrapper" style="width:' + width + 'px">' +
            '<div class="jGrid-illustration" style="background: white"><img src="' +
            image +
            '?ok" height="' +
            width +
            '" width="' +
            width +
            '"/></div>' +
            '</div>';
        },
        descriptionDownload: function(id){
            return tr('tracks_downloads_' + id);
        },
        formatTagsPublic: function(tags){
            var aTags = tags.split(",");
            var resp = '';
            for (i = 0, l = aTags.length; i < l; i++) {
                var tag = aTags[i];
                var hrefTag = J.fc.getUrl("search", "playlist", {
                    q: tag
                });
                if (i < l - 1) {
                    resp += '<a href=' + hrefTag + ' class="tag">' + tag + '</a>, ';
                }
                else {
                    resp += '<a href=' + hrefTag + ' class="tag">' + tag + '</a> ';
                }
            }
            return resp;
        },
        formatTags: function(tags){
            if (!tags || !tags.length) {
                return '';
            }
            var ans = '';
            for (var i = 0, l = tags.length; i < l; i++) {
                var tag = tags[i];
                var hrefTag = J.fc.getUrl("search", "playlist", {
                    q: tag
                });
                if (i < l - 1) {
                    ans += '<a href=' + hrefTag + ' class="tag">' + tag + '</a>, ';
                }
                else {
                    ans += '<a href=' + hrefTag + ' class="tag">' + tag + '</a> ';
                }
                
            }
            return ans;
        },
        formatArtists: function(data){
        
            if (data.page) {
                artists = data.page;
                
                if (!artists || !artists.length) {
                    return '';
                }
                var ans = '';
                for (var i = 0, l = artists.length; i < l; i++) {
                    var artist = artists[i];
                    var hrefTag = J.fc.getUrl("artist", artist.artistId);
                    if (i < l - 1) {
                        ans += '<a href=' + hrefTag + ' class="tag">' + artist.artistName + '</a>, ';
                    }
                    else {
                        ans += '<a href=' + hrefTag + ' class="tag">' + artist.artistName + '</a> ';
                    }
                    
                }
                return ans;
                
            }
            
            
            return '';
        },
        accesToCard: function(value){
            return tr('trackGrid_tip_' + value);
        },
        date: function(value){
        
            if (!value) {
                return '';
            }
            if (value) {
            }
            var now = new Date(value);
            
            return now.format("l d F Y - G:i");
        },
        dateBornRender: function(value){
        
            if (value) {
                var dt = Date.parseDate(value, "Y-m-d");
                var date = dt.format("d/m/Y");
            }
            else {
                var date = "";
            }
            
            return this.tjs_age(date);
        },
        privateRender: function(value){
        
            if (value) {
                return tr('private');
            }
            else {
                return tr('public');
            }
            
        },
        styleRender: function(value){
            if (value) {
                return aTr('themes', value);
            }
            else {
                return '';
            }
        },
        typeRender: function(value){
        
            if (value) {
                return aTr('type', value);
            }
            else {
                return '';
            }
            
        },
        relationchipRender: function(value){
        
            if (value) {
                return aTr('relationshipStatus', value);
            }
            else {
                return '';
            }
            
        },
        countriesRender: function(value){
            if (value) {
                return aTr('countries', value);
            }
            else {
                return '';
            }
        },
        providerRender: function(value){
        
            if (value) {
                return aTr('news_provider', value);
            }
            else {
                return '';
            }
            
        },
        dateRenderer: function(value){
        
            if (!value) {
                return '';
            }
            var diff = parseInt((now - value) / (60 * 60 * 1000 * 24), 0);
            if (diff == 0) {
                return tr('today');
            }
            else 
                if (diff == 1) {
                    return tr('yesterday');
                }
                else {
                    var now = new Date(value);
                    
                    return now.format(tr('formatDate'));
                }
        },
        isBoy: function(sex){
           
		   	return (sex == 'm');
        },
		 isWoman: function(sex){
          return (sex == 'f');
        },
		isNotPlayable: function(value){
            if (value == 2) {
                return true;
            }
            return false;
        },
        isRestricted: function(value){
            if (value == 1) {
                return true;
            }
            return false;
        },
		isset: function(value){
            if (value !== undefined && value != null && value != "" && value != "-") {
                return true;
            }
            return false;
        },
		 is: function(value){
            if (value !== undefined && value != null && value != "" && value != "-") {
                return value;
            }
            return false;
        },
        smallText: function(value){
        
            return J.render.reduce(value, 35);
        },
        midllereduce: function(value){
        
            return J.render.reduce(value, 90);
        },
        normalreduce: function(value){
            return J.render.reduce(value, 300);
        },
        Bigreduce: function(value){
            if (value.length > 450) {
                var pos = value.indexOf('<br\/><br\/>');
                if (pos) {
                    value = value.substr(0, pos);
                }
            }
            return J.render.reduce(value, 700);
        },
        mine: function(){
            return J.fc.controller.mine();
        },
        timeToStr: function(value){
            var s = "";
            
            var mins = parseInt(value / 60);
            var secs = parseInt(value - mins * 60);
            
            if (secs < 0) {
                secs = 0;
            }
            
            s = mins + ':';
            if (secs < 10) {
                s += '0';
            }
            
            
            s += secs;
            return s;
        },
        CheckDate: function(d){
            // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
            // Le séparateur est défini dans la variable separateur
            var amin = 1850; // année mini
            var amax = 2500; // année maxi
            var separateur = "/"; // separateur entre jour/mois/annee
            var j = (d.substring(0, 2));
            var m = (d.substring(3, 5));
            var a = (d.substring(6));
            var ok = 1;
            if (((isNaN(j)) || (j < 1) || (j > 31)) && (ok == 1)) {
                //alert("Le jour n'est pas correct.");
                ok = 0;
            }
            if (((isNaN(m)) || (m < 1) || (m > 12)) && (ok == 1)) {
                //alert("Le mois n'est pas correct.");
                ok = 0;
            }
            if (((isNaN(a)) || (a < amin) || (a > amax)) && (ok == 1)) {
                //alert("L'année n'est pas correcte.");
                ok = 0;
            }
            if (((d.substring(2, 3) != separateur) || (d.substring(5, 6) != separateur)) && (ok == 1)) {
                //alert("Les séparateurs doivent être des " + separateur);
                ok = 0;
            }
            if (ok == 1) {
                var d2 = new Date(a, m - 1, j);
                j2 = d2.getDate();
                m2 = d2.getMonth() + 1;
                a2 = d2.getYear();
                if (a2 <= 100) {
                    a2 = 1900 + a2
                }
                if ((j != j2) || (m != m2) || (a != a2)) {
                    //alert("La date " + d + " n'existe pas !");
                    ok = 0;
					return ok;
                }
                ok = d2;
            }
            return ok;
        },
        tjs_age: function(dt){
            // Cette fonction retourne une chaîne de type :
            // "15 ans et 6 mois"
            var d = this.CheckDate(dt)
            var m = new Date()
            var age = "";
            var age_a = 0;
            var age_m = 0;
            if (d != 0) {
                if (d.getTime() > m.getTime()) {
                    age = "La date de naissance est supérieure à la date du jour !";
                    document.formage.dt_naissance.focus();
                }
                age_a = m.getFullYear() - d.getFullYear();
                m.setYear(d.getYear());
                if ((d.getTime() > m.getTime()) && (d.getMonth() - m.getMonth() != 0)) {
                    age_a--;
                }
                if (d.getMonth() >= m.getMonth()) {
                    age_m = 12 - (d.getMonth() - m.getMonth())
                }
                else {
                    age_m = (m.getMonth() - d.getMonth())
                }
                if (age_m == 12) {
                    age_m = 0;
                }
                if (age_a == 1) {
                    age = age_a + " an"
                }
                if (age_a > 1) {
                    age = age_a + " ans"
                }
                if ((age_a > 0) && (age_m > 0)) {
                    age += " et "
                }
                if (age_m > 0) {
                    age += age_m + " mois"
                }
                if (age == "") {
                    age = "moins de 1 mois"
                }
            }
            else {
                //document.formage.dt_naissance.focus();
				return false;
            }
            return age;
        }
    }
    
}();

J.render.ellipsis = J.render.ellipsis;

J.render.arrTr = arrTr;
J.render.tr = tr;
/**
 * @author admin
 
J.Zedo = function() {

	return {
		tag : function(tag) {
			var pages = {
				"home-na" :0,
				"home" :1,
				"search" :2,
				"play" :3,
				"play-radio" :4,
				"hit" :5,
				"radio" :6,
				"signup" :7,
				"signup-done" :8,
				"login" :9
			};
			var i = pages[tag];
			if (i === undefined) {
				console.warn("Unknown tag", tag);
				return;
			}
			var o = 145233 + i;
			var zzp = new Image();
			if (location.protocol == "https:") {
				zzp.src = "https://ss1.zedo.com/ads2/t?o" + o + ";h=527678;z=" + Math.random();
			} else {
				zzp.src = "http://xads.zedo.com/ads2/t?o=" + o + ";h=527678;z=" + Math.random();
			}
		}
	}
}();

*/


J.trackArray = function(arr){

    var page = '/' + arr.join('/');
    page = page.replace(/%20/g, "_");
    //console.log("----------", page, "----------");
    if (pageTracker) {
    
        pageTracker._trackPageview(page);
    }
};

var pageTracker;

J.track = function(controller, action, id, id2, id3, id4, id5, id6){
    var x = [];
	
	 if (_gat != undefined && pageTracker==undefined) {
                        pageTracker = _gat._getTracker("UA-1245632-4");
                        pageTracker._setDomainName("none");
                        pageTracker._setAllowLinker(true);
          pageTracker._initData();
      }
    
    if (controller !== undefined) {
        x.push(controller);
        if (action !== undefined) {
            x.push(action);
            if (id !== undefined) {
                x.push(id);
                if (id2 !== undefined) {
                    x.push(id2);
                    if (id3 !== undefined) {
                        x.push(id3);
                        if (id4 !== undefined) {
                            x.push(id4);
                            if (id5 !== undefined) {
                                x.push(id5);
                                if (id6 !== undefined) {
                                    x.push(id6);
                                }
                            }
                        }
                    }
                }
            }
        }
        
    }
    var page = '/' + x.join('/');
    page = page.replace(/%20/g, "_");
    if (pageTracker) {
    
        pageTracker._trackPageview(page);
    }
};

J.hit = function(type){
    if (type === undefined) {
    
    }
    else {
        J.track('hit', type);// , artistId, albumId, songId,
    }
};


J.Record.News = Ext.data.Record.create([{
	name: 'newsId',
	type: 'int'
}, {
	name: "title",
	type: 'string'
},  {
	name: "thread",
	type: 'string'
},{
	name: "languageId",
	type: 'int'
},{
    name: "permalink"
},{
	name: "objId",
	type: 'int'
}, {
	name: "linkUrl",
	type: 'string'
}, {
	name: "publishDate",
	type: 'date',
	dateFormat: "Y-m-d H:i:s"
},{
	name: "data",
	type: 'string'
}, {
	name: "dataType",
	type: 'int'
}, {
	name: "objId",
	type: 'int'
}, {
	name: "abstract",
	type: 'string'
}, {
	name: "text",
	type: 'string'
}, {
	name: "artists"
},  {
	name: "isInternal",
	type: 'boolean'
}, {
	name: "categories",
	type: 'string'
}, {
	name: "provider",
	type: 'string'
}, {
	name: "externalId",
	type: 'string'
}, {
	name: "type",
	type: 'int'
},{
	name: "hasPicture",
	type :'boolean'
}, {
	name: "format",
	type: 'int'
}, {
	name: "ownerType",
	type: 'int'
}, {
	name: "ownerId",
	type: 'int'
},  {
	name: "state",
	type: 'int'
}, {
	name: "tags",
	type: 'string'
}, {
	name: "editoTitle",
	type: 'string'
}, {
	name: "editoSubTitle",
	type: 'string'
}, {
	name: "editoLink",
	type: 'string'
}, {
	name: "editoLinkName",
	type: 'string'
}, {
	name: "editoTrackId",
	type: 'int'
}, {
	name: "editoIsReady",
	type: 'boolean'
}]);
J.Record.Playlist = Ext.data.Record.create([{
    name: 'playlistId'
}, {
    name: 'playlistName'
},{
	name: "inRecommendation",
	type :'boolean'
}, {
    name: 'modificationDate',
	type:'date',
	dateFormat: 'Y-m-d H:i:s'
}, {
    name: 'nbSongs'
},{
    name: 'tags'
},{
    name: "permalink"
}, {
    name: 'ownerId'
}, {
    name: 'ownerName'
}, {
    name: 'playlistFolder'
}, {
    name: 'playlistPopularity',
	type:'int'
}, {
    name: 'private',
	type:'bool'
}, {
    name: 'style'
}, {
    name: 'description'
}, {
    name: 'nbSubscribers',
	type:'int'
},{
	name: "hasPicture",
	type :'boolean'
}]);
J.Record.FavoritePlaylist = Ext.data.Record.create([{
    name: 'playlistId'
}, {
    name: 'playlistName'
}, {
    name: 'modificationDate',
	type:'date',
	dateFormat: 'Y-m-d H:i:s'
}, {
    name: 'nbSongs'
}, {
    name: 'ownerId'
}, {
    name: 'ownerName'
},{
	name: "hasPicture",
	type :'boolean'
}]);J.Record.Track = Ext.data.Record.create([{
    name: 'trackId'
}, {
    name: 'songId'
}, {
    name: 'albumId'
}, {
    name: 'artistId'
},{
    name: 'sourceId'
},{
    name: 'sourceType'
},{
    name: "permalink"
},{
    name: 'tags'
},{
    name: 'songName'
},{
	name: 'itunesTrackUrl'	
},{
	name: 'starzikTrackUrl'	
}, {
    name: 'albumName'
}, {
    name: 'artistName', mapping: 'artistName'
}, {
    name: 'songPopularity'
}, {
    name: 'progression',
	type:'int'
},{
    name: 'rank',
	type:'int'
},{
    name: 'duration',
	type:'int'
}, {
    name: 'artists'
}, {
    name: 'secArtistsNames'
}, {
    name: 'style'
}, {
    name: 'styleSecondary'
}, {
    name: 'albumReleaseDate',type:'date',dateFormat: 'Y-m-d'
},{
	name: "hasPicture",
	type :'boolean'
},{
	name: "full",
	type :'boolean'
},{
	name: "ad",
	type :'string'
}, {
    name: 'duration',
	type:'int'
}, {
    name: 'random',
	type:'float'
}, {
    name: 'hidden',
	type:'boolean'
},{
	name: 'restricted',
	type: 'int'
}
]);

J.Record.Artist = Ext.data.Record.create([{
    name: 'artistId'
}, {
    name: "artistName",
    type: 'string'
},{
    name: 'tags',
	type: 'string'
},{
    name: "biography"
},{
    name: "similarArtists"
},{
    name: "permalink"
},{
    name: "nbSubscribers",
	type:'int'
},{
    name: 'progression',
	type:'int'
},{
    name: "nbSongs",
	type:'int'
},{
    name: "artistPopularity",
	type:'int'
}, {
    name: 'style'
}, {
    name: 'styleSecondary'
}, {
    name: 'artists'
},{
	name: "hasPicture",
	type :'boolean'
}, {
    name: 'hidden',
	type:'boolean'
}
]);J.Record.Radio = Ext.data.Record.create([{
    name: 'radioId',
    type: 'int'
}, {
    name: "radioUrl",
    type: 'string'
}, {
    name: "radioImg",
    type: 'string'
},{
    name: "radioName",
    type: 'string'
},{
    name: "permalink"
},{
    name: "radioDescription",
    type: 'string'
},{
    name: "radioNbFans",
    type: 'int'
},{
    name: "radioMain",
    type: 'int'
},{
    name: "radioPromo",
    type: 'int'
},
{
    name: "radioTags",
    type: 'string'
},{
    name: "radioPopularity",
    type: 'int'
},{
    name: "radioOwnerId",
    type: 'int'
},{
    name: "radioOwnerName",
    type: 'string'
},{
	name: "hasPicture",
	type :'boolean'
},{
    name: 'style'
},{
    name: "nbSubscribers",
	type:'int'
}
]);
J.Record.Album = Ext.data.Record.create([{
    name: 'albumId',
    type: 'int'
}, {
    name: "albumName",
    type: 'string'
},{
	name: "hasPicture",
	type :'boolean'
},{
	name: "inRecommendation",
	type :'boolean'
},{
    name: 'tags'
},{
    name: "artists"
},{
    name: 'progression',
	type:'int'
},{
    name: "artistName"
},{
    name: "permalink"
},{
    name: "itunesUrl"
},{
    name: "starzikUrl"
},{
    name: "artistId"
},{
    name: "releaseDate",
    type: 'date',
	dateFormat: 'Y-m-d'
},{
    name: "nbSubscribers",
	type:'int'
},{
    name: "nbSongs",
	type:'int'
},{
    name: "albumPopularity",
	type:'int'
}, {
    name: 'style'
}, {
    name: 'styleSecondary'
},{
    name: 'hidden',
	type:'boolean'
},{
	name: 'restricted',
	type: 'boolean'
}
]);
J.Record.FavoriteAlbum = Ext.data.Record.create([{
    name: 'albumId',
    type: 'int'
}, {
    name: "albumName",
    type: 'string'
},{
	name: "hasPicture",
	type :'boolean'
}
]);
J.Record.User = Ext.data.Record.create([{
    name: 'userId'
}, {
    name: 'userName'
},  {
    name: 'ownerId'
},{
    name: 'ownerName'
},{
	name: "inRecommendation",
	type :'boolean'
}, {
    name: 'age'
}, {
    name: 'country'
}, {
    name: 'countryId'
},{
    name: "permalink"
}, {
    name: 'email',
	type:'string'
},{
    name: 'languages'
},{
    name: 'userPicture'
}, {
    name: 'town'
}, {
    name: 'interestedIn'
}, {
    name: 'sex'
},{
	name:'relationshipStatus'
},{
	name:'tastes'
},{
    name: "nbSubscribers",
	type:'int'
},{
    name: "userPopularity",
	type:'int'
}, {
    name: 'style'
}, {
    name: 'tags'
}, {
    name: 'bornDate'
}, {
    name: 'postalCode',
	type:'string'
}, {
    name: 'partnerContact'
}, {
    name: 'supporter',
	type:'boolean'
} , {
    name: 'newsletterContact',
	type:'boolean'
} ,{
	name: "hasPicture",
	type :'boolean'
},{
	name: "topcard"
}, {
    name: 'releaseNotification',
	type:'boolean'
} , {
    name: 'commentNotification',
	type:'boolean'
} , {
    name: 'subscribeNotification',
	type:'boolean'
} , {
    name: 'messageNotification',
	type:'boolean'
} ]);J.Record.Suggestion = Ext.data.Record.create([
{
	name: 'id'
},{
    name: 'trackId'
}, {
    name: 'songId'
}, {
    name: 'albumId'
}, {
    name: 'artistId'
}, {
    name: 'userId'
}, {
    name: 'sex'
}, {
    name: 'songName'
},{
	name: 'itunesTrackUrl'	
},{
	name: 'starzikTrackUrl'	
}, {
    name: 'albumName'
},{
    name: 'secArtistsNames'
}, {
    name: 'artistName'
}, {
    name: 'userName'
}, {
    name: 'suggestionDate',type:'date',dateFormat: 'Y-m-d H:i:s'
}, {
    name: 'text'
}, {
    name: 'songPopularity'
}, {
    name: 'userPicture',
	type: 'string'
}]);


J.Record.Comment = Ext.data.Record.create([{
    name: 'commentId',
	type: 'int'
}, {
    name: 'insertDate',
	type:'date',
	dateFormat: 'Y-m-d H:i:s'
}, {
    name: 'body',
	type: 'string'
}, {
    name: 'userId',
	type: 'int'
},  {
    name: 'sex',
	type: 'string'
}, {
    name: 'userName',
	type: 'string'
}, {
    name: 'userPicture',
	type: 'string'
}]);
J.Record.Mail = Ext.data.Record.create([
{name: 'inMailId'},
{name: 'userId'},
{name: 'userName'},
{name: 'userPicture'},
{name: 'sex'},
{name: 'recipients'},
{name: 'recipientsNamesPreview'},
{name: 'sentTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s'},
{name: 'subject'},
{name: 'readFlag'},
{name: 'bodyPreview'},
{name: 'body'}, {
    name: 'userPicture',
	type: 'string'
}
]);

J.Record.outMail = Ext.data.Record.create([
{name: 'outMailId'},
{name: 'userId'},
{name: 'userName'},
{name: 'userPicture'},
{name: 'sex'},
{name: 'recipients'},
{name: 'recipientsNamesPreview'},
{name: 'sentTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s'},
{name: 'subject'},
{name: 'readFlag'},
{name: 'bodyPreview'},
{name: 'body'}, {
    name: 'userPicture',
	type: 'string'
}
]);
J.Record.Home = Ext.data.Record.create([{
	name: 'homeId',
	type: 'int'
}, {
	name: "title",
	type: 'string'
},{
	name: "languageId",
	type: 'int'
}, {
	name: "content"
}, {
	name: "selected",
	type: 'boolean'
}]);
J.Record.Translation = Ext.data.Record.create([
{
    name: 'translationLabelId',
    type: 'int'
},{
    name: 'translationLabelName',
    type: 'string'
},{
    name: 'translationId',
    type: 'int'
},{
    name: 'languageId',
    type: 'int'
},{
    name: 'description',
    type: 'string'
},{
    name: 'updateDate',
    type: 'string'
},{
    name: 'translation',
    type: 'string'
}
]);
J.Model.BaseModel = function(p){
	if(p.controller) {	
			this.controller = p.controller;
			this.url= this.controller.baseUrl;
	}
};

J.Model.BaseModel.prototype = {
    destroy: function() {
		if(this.store){			
			this.store.destroy();
		}
		if(this.reader){			
			this.reader.destroy();
		}
	
    },
    /**
     * Creates and launch an ajax request.
     * @param {Object} defaultP can contain url, callback, scope, params, inc
     * @param {Object} p can contain params, tmp, callback, scope, data, addInc, remInc, setInc
     */
    jwRequest: function(defaultP) {
		
        var reqParams = {};
		
        reqParams.url = defaultP.url;
        reqParams.callback = function(options, success, response) {
            // Decode data assuming it is JSON
            var ans = Ext.jwDecode(options, success, response);
            
			if(ans.success == false){
				
				try {
		            json = Ext.decode(ans.responseText);
		          
					if(json.success ==false){
						if(json.errors.msg !=undefined){
							J.InfoBox.msg(tr(json.errors.msg),4);
						}else if(typeof(json.errors) == 'string'){
							J.InfoBox.msg(tr(json.errors),4);
						}
						
						return false;
					}
		        } 
		        catch (e) {
		          
		        }
	
			}
		
			
			if (defaultP.callback) {
                //if (!Ext.callback(defaultP.callback, defaultP.scope || this, [data.success, data])) {
                if (false === defaultP.callback.call(defaultP.scope || this, ans.success, ans)) {
                    // Internal callback has failed
                    throw ("Internal callback has failed");
                    return false;
                }
            }
        };
        reqParams.scope = defaultP.scope || this;
        
       reqParams.params = defaultP.params;
	   
	   
   
       
        return Ext.Ajax.request(reqParams);
    },
    setData: function(field, value) {
        return this.data.add(field, value);
    },
    getField: function(fieldName) {
    	if(this.record){
        return this.record.get(fieldName);
    	}
    },
    updateRecord: function(data) {
        if (!data) {
            data = {};
        }
        
        // Try to get a record
        if (this.recordType) {
            var fields = this.recordType.prototype.fields, fieldsItems = this.recordType.prototype.fields.items, fieldsLength = fields.length, field;
            
            var values = {};
            for (var i = 0; i < fieldsLength; i++) {
                field = fieldsItems[i];
                var v = data[field.name];
                values[field.name] = field.convert((v !== undefined && v != null) ? v : field.defaultValue, data);
            }
            var id = values[this.recordId];
            this.record = new this.recordType(values, id);
            this[this.recordId] = id;
			
		  if(this.controller){
		  	J.fc.controller.refresh();
		  }  
		  
		 
        }
        
       
    },
    
    updateData: function(data) {
        for (key in data) {
            var value = data[key];
         	 this.data.replace(key, value); 
        }
    },  update: function(data) {
        if (!data) {
            data = {};
        }
        if (data) {
            this.updateRecord(data);
        }
    }

};


J.Model.Player =function(p){
	p = p ? p : {};
    J.Model.Player.superclass.constructor.call(this, p);

    this.reader = new Ext.data.JsonReader({}, J.Record.Track);
    
    this.store = new Ext.data.Store({
        reader: this.reader
    });	
	
	this.radioStore = new Ext.data.Store({
		reader:new Ext.data.JsonReader({id: "songId"}, J.Record.Track)
    });
};

Ext.extend( J.Model.Player, J.Model.BaseModel, {
	MAX_SUGGESTIONS: 8,
    paused : false,
    shuffle : false,
	restricted: true,
    repeat : false,
    volume : 0.95,
	radioIndex:0,
	suggestions :{page:[]},
	params: {},
	radioParams: {},
    setPaused: function(paused) {
        this.paused = paused;
    },
    getPaused: function() {
        return this.paused;
    },
    setShuffle: function(shuffle) {
      
		if(shuffle && (this.shuffle!= shuffle )){
			var random = true;
        // Transform tracks into records
       
			this.radioStore.each(function(record){
				if(random){
					record.set('random',Math.random()*Math.random());
				}else{
					record.set('random',Math.random()+Math.random());
				}
				random = !random;
			});
			
			this.radioStore.sort('random');
		}
		this.shuffle = shuffle;
		
    },
    getShuffle: function() {
        return this.shuffle;
    },
	setRepeat: function(repeat) {
        this.repeat = repeat;
    },
	setRestricted: function(restricted) {
        this.restricted = restricted;
		
		
		if(this.controller.mode == "ON_DEMAND" && restricted == true){
			this.store.each(function(track,a,b,c,d,e) {
			
				if(track.data.restricted!=0){
								this.store.remove(track);
					}
		        },this);
		
		}
    },
    getRepeat: function() {
        return this.repeat;
    },
    
    getVolume: function() {
        return this.volume;
    },
    setVolume: function(vol) {
        this.volume = vol;
    },
    setRadioTracks: function(previousTracks, currentTrack, nextTracks) {
		var data = [];
		
        this.store.removeAll();
		
		data.push({
            songId: -1,
			songName: "<div class='player-track-title'>"+tr('tracks_played')+"</div>"
        });
        data.push(previousTracks);
	
		// Current
        data.push({
            songId: -2,
			songName: "<div class='player-track-title'>On Air</div>"
        });
        data.push(currentTrack);
     
		// Current
        data.push({
            songId: -3,
			songName: "<div class='player-track-title'>"+tr('tracks_coming')+"</div>"
        });
		
       data = data.concat(nextTracks);
	   this.store.loadData(data);
		
    },
    /**
     * Add tracks (array of associative arrays) to the queue after transforming them into records.
     * @param {Array of Arrays} tracks
     * @param {int} insertIndex
     */
    addTracks: function(tracks,options) {
		if(this.controller.mode != "ON_DEMAND") {
			this.store.removeAll();
			this.radioStore.removeAll();
		}
			
        var records = [];
        
		var random = true;
        // Transform tracks into records
        Ext.each(tracks, function(track,a,b) {
			
			if (track != null) {
				if (this.shuffle) {
					if (random) {
						track.random = Math.random() + Math.random();
					}
					else {
						track.random = Math.random() * Math.random();
					}
					random = !random;
				}
				
				if (location.host == 'tamtam.jiwa' || location.host == 'beta.jiwa.fm'|| location.host == 'test.jiwa.fm') {
					track.full = true;
				}
				
				if (options.sourceType != undefined) {
					track.sourceId = options.sourceId;
					track.sourceType = options.sourceType;
				}
				else {
					if (J.fc.name) {
						track.sourceType = J.fc.name;
					}
					if (J.fc.controller.id) {
						track.sourceId = J.fc.controller.id;
					}
					
					if (J.fc.name == 'playlist') {
						var style = J.fc.controller.model.record.data.style;
						if (style == 'classic' || style == 'jazz') {
							track.ad = 'playlist';
						}
					}
				}
				
				var record = new J.Record.Track(track);
				if(track.restricted !=2){
					if (this.restricted == false) {
						records.push(record);
						
					}else if (track.restricted == 0) {
						records.push(record);
						
					}
				}
				
				
					
				
			}else{
						b.remove(track);
			}
        }, this);
		
		
		if (this.controller.mode == "ON_DEMAND") {
			var index = this.store.getCount();
		}
        
        this.store.add(records);
		this.radioStore.addSorted(records);
		
		
		if (this.controller.mode == "ON_DEMAND") {
			if (options.play) {
				this.playIndex(index);
			}
		}
    },
  	reqSimilarTracks: function(p) {
		
		if(J.dev ==true){
			return;
		}
		
        return this.jwRequest({
            url: "/track/socialsuggestions",
            params: {
                trackId: p.trackId
            },
            callback: function(success, data) {
                if (success) {
                  
				  if(this.controller.currentTrack.trackId == p.trackId){
				  	this.suggestions = data ;
					this.controller.view.createSimilarTrackZone();
				  }  
					
                }
            }
        }, p);
	
	},
	LoadRadioList: function(list,params) {

			var timedate = new Date();
			var hour = timedate.getHours();
			var minutes = timedate.getMinutes();
			var playlistDuration = list.length*4;
			var time = minutes + hour*60;
			var position = parseInt((time % playlistDuration )/4);
		
		/*if (params.type = 'radio') {
			if (params.radioId == 3 || params.radioId == 6 || params.radioId == 20) {
				params.ad = 'radio';
			}
			
		}
		
		*/
			
			Ext.each(list, function(track,a,b) {
		
		if (track != null) {
			
	
		track.sourceId =params.radioId;
		track.sourceType =params.type;
		track.full =true;
		
			if (params.ad != undefined) {
					track.ad = params.ad;
				}
				
		}else{
						b.remove(track);
			}
          
        }, this);
		
			var last = list.splice(0,position);
			
			 
			this.radioStore.loadData(list);
			this.radioStore.loadData(last,true);
			
				var last =this.radioStore.getAt(this.radioIndex-1);
					var record =this.radioStore.getAt(this.radioIndex);
					var next1 =this.radioStore.getAt(this.radioIndex+1);
					var next2 = this.radioStore.getAt(this.radioIndex+2);
					
					if(!record){
						record ={
							record:{}
						};
					}
					
					if(!next1){
						next1 ={
							data:{}
						};
					};
					if(!next2){
						next2 ={
							data:{}
						};
					};
					
					if(!last){
						last ={
							data:{}
						};
					};
					this.setRadioTracks(last.data,record.data,[next1.data,next2.data]);
		
	
			this.controller.jwPlayTrackAtIndex(this.radioStore.getAt(0).data,3);

	},
	getTrackAtIndex:function(index,mode){
		
		if(mode != "ON_DEMAND"){
			index = 5;
		}
	
		var record = this.store.getAt(index);
		
		if( mode == "ON_DEMAND" ){
					if (record) {
						return record.data;
					}
		}else{
				this.radioIndex++;
				
					var last =this.radioStore.getAt(this.radioIndex-1);
					var record =this.radioStore.getAt(this.radioIndex);
					var next1 =this.radioStore.getAt(this.radioIndex+1);
					var next2 = this.radioStore.getAt(this.radioIndex+2);
					
					if(!record){
						record ={
							record:{}
						};
						
						var record = this.store.getAt(3);
			
						if(record){
							var params = {
								type: this.radioParams.type,
								radioId:this.radioParams.radioId
							};
							params.trackId = record.data.trackId;
							this.launchRadio(params,this.controller.mode);
							return;
						}
					}
					
					if(!next1){
						next1 ={
							data:{}
						};
					};
					if(!next2){
						next2 ={
							data:{}
						};
					};
					
					if(!last){
						last ={
							data:{}
						};
					};
					this.setRadioTracks(last.data,record.data,[next1.data,next2.data]);
					return record.data;
				}
				
	},
	launchRadio: function(params,mode) {
		this.controller.mode = mode ;
		this.radioParams = params;
		
		this.controller.view.refreshMode();
		if(mode == "INTERACTIVE_RADIO"){
			mode = "similiradio"
		}else{
			mode="radio";
		}
		
		
		
		var url = "/"+mode+"/tracks";
		
		if(params.type== 'playlist'){
			var url = "/playlist/tracks";
			params = {
				playlistId: params.radioId
			};
		}
		
		params.limitTracks =1000;
	
		
		
        Ext.MessageBox.wait(tr('popup_msg_wait'));
        return this.jwRequest({
            url: url,
            params: params,
            callback: function(success, data) {
                if (success) {
					this.radioIndex=0;
					this.LoadRadioList(data.page,params);
					
                }
            }
        });
		

		
	},
	launchPlaylist: function(playlistId,options) {
		this.controller.mode = "ON_DEMAND";
		options.play =true;
		options.sourceId =playlistId;
		options.sourceType ='playlist';
		
	/*if (J.fc.name == 'playlist') {
			var style = J.fc.controller.model.record.data.style;
			if (style == 'classic' || style == 'jazz' ) {
					options.ad = 'playlist';
			}
		}
*/

		params.limitTracks =1000;
	
        Ext.MessageBox.wait(tr('popup_msg_wait'));

		return this.jwRequest({
            url: "/playlist/tracks",
            params: {
				playlistId :playlistId,
				limitTracks : 1000
            },
     callback: function(success, data) {
                if (success) {
					this.clearQueue();
					this.addTracks(data.page,options);
					
                }
            }
        });
	},
	launchAlbum: function(albumId,options) {
		this.controller.mode = "ON_DEMAND";
		options.play =true;
		options.sourceId =albumId;
		options.sourceType ='album';
		return this.jwRequest({
            url: "/album/tracks",
            params:{
				albumId :albumId,
				limitTracks : 500
            },
            callback: function(success, data) {
                if (success) {
					this.clearQueue();
					this.addTracks(data.page,options);
					
                }
            }
        });
	},
	launchTrack: function(trackId,options) {
		if(this.controller.mode != "ON_DEMAND") {
			this.store.removeAll();
			this.radioStore.removeAll();
		}
		
		this.controller.mode = "ON_DEMAND";
		options.play =true;
		options.sourceId =trackId;
		options.sourceType ='track';
		
	
		return this.jwRequest({
            url: "/track/details",
            params:{
				trackId :trackId
            },
            callback: function(success, data) {
                if (success) {
					this.addTracks([data.track],options);
                }
            }
        });
	},
	playIndex :function(index){
		if(this.controller.mode == "ON_DEMAND"){
			
			 var record = this.store.getAt(index);
			 
			 
			 if(record){
			 	
			 	this.controller.jwPlayTrackAtIndex(record.data,index);
			 }

		}
	},
    removeTracks: function(firstIndex, nbTracks) {
		if(this.controller.mode != "ON_DEMAND") {
			this.controller.mode = "ON_DEMAND";
			this.clearQueue();
		}
		
        for (var i = firstIndex; i < firstIndex + nbTracks; i++) {
            this.store.remove(this.store.getAt(firstIndex));
        }
    },
    clearQueue: function() {
		if(this.controller.mode == "ON_DEMAND"){
			this.store.removeAll();
			this.radioStore.removeAll();
		}
       
    },
    
    removeAt: function(index){
		if (this.controller.mode == "ON_DEMAND") {
			this.store.removeAt(index);
		}
	}   
    
});

J.Model.Mail =function(p){ 
	p = p ? p : {};	
	this.store = p.store;
	J.Model.Mail.superclass.constructor.call(this, p);
};

Ext.extend( J.Model.Mail, J.Model.BaseModel, {

	addMail: function(value) {
			
		var params = {};
		Ext.MessageBox.wait(tr('newMail_msg_sending')+"...");



		params.body = value.body;
		
		
		
		if(this.store){
			var base  = this.store.getAt(0).data;
		
			if(base.userName){
					value.subject = base.subject;
					value.userName = base.userName;
			}
		}
		
		
		if(value.subject == undefined){
			value.subject ='';
		}
		
		
		params.subject = "RE : "+value.subject;
		params.recipientsNames = value.userName;
		
		return this.jwRequest({
			url: "/user/outboxsend",
			params: params,
			callback: function(success, data) {
				if (success) {
					this.controller.view.onSuccess();
				}
			}
		});
	},
	reqDelete: function(id){
		if(id){
			var idToDelete = id;
		}else{
			var idToDelete = this.controller.id;
		}
		
		return this.jwRequest({
            url: "/user/inboxdelete",
            params: {
                inMailIds: idToDelete
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		if (J.fc.name) {
						J.InfoBox.msg(jTr('message_removed', J.fc.name));
					}
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}else{
						J.fc.jList.store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
	}
	
});

J.Model.PlaylistAdder =function(p){ 
	
p = p ? p : {};
	J.Model.PlaylistAdder.superclass.constructor.call(this,p);
	
	this.store = null;
	this.account = null;
	this.tracksRecords = null;	
	
};

Ext.extend(J.Model.PlaylistAdder, J.Model.BaseModel, {
	/***************************************************************************
	 * Static public functions
	 **************************************************************************/
	/***************************************************************************
	 * Public functions
	 **************************************************************************/
	getStore: function() {
		return this.store;
	},
	setTracksRecords: function(tracksRecords) {
		this.tracksRecords = tracksRecords;
	},
	getTracksIds: function() {
		var ids = [];
		
		if (this.tracksRecords) {
			Ext.each(this.tracksRecords.records, function(Track){
				ids.push(Track.data.trackId);
			}, this);
		}
		return ids;
	},
	/***************************************************************************
	 * Public actions
	 **************************************************************************/
	reqAddToPlaylists: function(playlistIds) {
		
		var tracks = this.getTracksIds();
		
		this.playlistIds = playlistIds;
		
		if (tracks.length > 0) {
			var position = 'begin';
			var radio = Ext.get('end-radio');
			if (radio) {
				if (radio.dom) {
					if (radio.dom.checked == true) {
						position = 'end';
					}
				}
			}
			
			Ext.MessageBox.wait(tr("popup_msg_wait"));
			
			return this.jwRequest({
				url: 'playlist/addtracks',
				params: {
					trackIds: tracks.join(','),
					playlistIds: playlistIds.join(','),
					position: position
				},
				scope: this,
				callback: this.trackAddedCallback
			});
			
		}else{
			if (this.controller.view.win) {
				this.controller.view.win.close();
			}
		}
	},
	reqRemoveFromPlaylist: function(tracks,playlistId,store,start,limit) {
			
		this.setTracksRecords(tracks);
		var ids = [];
		Ext.each(tracks, function(Track) {
			ids.push(Track.data.trackId);
		}, this);
		
		TracksIds  = ids.join(',');
		
		var params ={
				trackIds: TracksIds ,
				playlistId: playlistId,
				start : start,
				limit :limit
			};
			
		Ext.MessageBox.wait(tr("popup_msg_wait"));
		return this.jwRequest({
			url:'playlist/removetracks',
			params:params,
				callback: function(success,data){
			
            		if (success == true) {
						store.removeAll();
						store.reload();
					}else{
            			J.InfoBox.msg(tr('ERR__ERROR'));
            		}
				
				}
				
			
		});
	},
		reqMoveFromPlaylist: function(tracks,playlistId,store,position,start,limit) {
			
		this.setTracksRecords(tracks);
		var ids = [];
		Ext.each(tracks, function(Track) {
			ids.push(Track.data.trackId);
		}, this);
		
		TracksIds  = ids.join(',');
		
		var params ={
				trackIds: TracksIds ,
				playlistId: playlistId,
				position :position,
				start : start,
				limit :limit
			};
		Ext.MessageBox.wait(tr("popup_msg_wait"));
		return this.jwRequest({
			url:'playlist/movetracks',
			params:params,
			callback: function(success,data){
				
				if(success == true ){
            	
					if (success == true) {
						store.removeAll();
						store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
				
				
			}
		});
	},
	trackAddedCallback: function() {
		J.InfoBox.msg(tr('track_added_to_playlist'));
		
		if(J.fc.controller.baseUrl=="playlist"){
			if(this.playlistIds[0] == J.fc.controller.id){
				J.fc.grid.store.reload();
			}
		}
		
		if (this.controller.view.win) {
			this.controller.view.win.close();
		}
	}
	
	/***************************************************************************
	 * Private functions
	 **************************************************************************/
	/***************************************************************************
	 * Callbacks
	 **************************************************************************/
});


J.Model.Home= Ext.extend( J.Model.BaseModel, {
 /***************************************************************************
     * Public functions
     **************************************************************************/
    reqData: function(){
       
	   var model=this;
        return this.jwRequest({
            url: "/home/selected",
            params: {
				languageId:J.languageId,
				withNews:true
            },
            callback: function(success, data) {
                if (success) {
					if(data.home){
						model.controller.view.render(data.home.content);
					}
                }else{
					model.controller.view.render(false);
				}
				Ext.MessageBox.hide();
            }
        }, {});
	 
    }
});

J.Model.Focus =function(p){ 
	
	p = p ? p : {};
	J.Model.Focus.superclass.constructor.call(this,p);
	
	this.data = arrTr("player_edito_multi_preview");
	/*
	 this.data[3] ={
		title: tr('jiwa_offer_download'),
		subtitle : tr('free_download'),
		link:tr('acces_download'),
		url:'account/download',
		img : 'http://medias.jiwa.fm/edito/494/download.jpg',
		download:true
	};
	
	*/
};


Ext.extend( J.Model.Focus ,J.Model.BaseModel, {
	
	getAllData: function() {
		return this.data;
	},
	
	getData: function(i) {
		return this.data[i];
	},
	updateDataPreview: function(data){
		this.data = data;
		return true;
	},
	editoPreview:function(i){
		return this.jwRequest({
            url: "/news/editopreview",
			params:{
				languageId:J.languageId
			},
            callback: function(success, data) {
                if (success) {
					this.updateDataPreview(data.preview);
					J.fc.getController("home",true).updateFocus();
					J.InfoBox.msg("Preview Correctement Generer");
				}
            }
        }, {});
	},
	editoGeneration:function(i){
		return this.jwRequest({
            url: "/news/editogeneration",
			params:{
				languageId:J.languageId
			},
            callback: function(success, data) {
                if (success) {
					this.updateDataPreview(data.preview1);
					J.fc.getController("home",true).updateFocus();
					J.InfoBox.msg("Preview Correctement Generer");
				}
            }
        }, {});
	}
	
});

J.Model.Mail =function(p){ 
	p = p ? p : {};	
	this.store = p.store;
	J.Model.Mail.superclass.constructor.call(this, p);
};

Ext.extend( J.Model.Mail, J.Model.BaseModel, {

	addMail: function(value) {
			
		var params = {};
		Ext.MessageBox.wait(tr('newMail_msg_sending')+"...");



		params.body = value.body;
		
		
		
		if(this.store){
			var base  = this.store.getAt(0).data;
		
			if(base.userName){
					value.subject = base.subject;
					value.userName = base.userName;
			}
		}
		
		
		if(value.subject == undefined){
			value.subject ='';
		}
		
		
		params.subject = "RE : "+value.subject;
		params.recipientsNames = value.userName;
		
		return this.jwRequest({
			url: "/user/outboxsend",
			params: params,
			callback: function(success, data) {
				if (success) {
					this.controller.view.onSuccess();
				}
			}
		});
	},
	reqDelete: function(id){
		if(id){
			var idToDelete = id;
		}else{
			var idToDelete = this.controller.id;
		}
		
		return this.jwRequest({
            url: "/user/inboxdelete",
            params: {
                inMailIds: idToDelete
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		if (J.fc.name) {
						J.InfoBox.msg(jTr('message_removed', J.fc.name));
					}
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}else{
						J.fc.jList.store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
	}
	
});
J.Model.Comment =function(p){ 
	p = p ? p : {};	
	this.store = p.store;
	J.Model.Comment.superclass.constructor.call(this, p);

};

Ext.extend( J.Model.Comment, J.Model.BaseModel, {

	addComment: function(value) {
		var params = this.store.baseParams;
	
		params.body = value.body;
		Ext.MessageBox.wait(tr('newMail_msg_sending')+"...");
		return this.jwRequest({
			url: "/"+J.fc.controller.model.url+"/addcomment",
			params: params,
			callback: function(success, data) {
				if (success) {
					this.store.loadData(data.comments);
					this.controller.view.onSuccess();
					
				}
			}
			
		});
	},
	deleteComment: function(commentId) {
		var params = this.store.baseParams;
		params.commentId= commentId;
		
		Ext.MessageBox.wait(tr('newMail_msg_sending')+"...");
		return this.jwRequest({
			url: "/comment/delete",
			params: params,
			callback: function(success, data) {
			
				if (success) {
					this.store.loadData(data.comments);
					
				}
			}
			
		});
	}
	
});


J.Model.Text = Ext.extend( J.Model.BaseModel, {
  	 /*******************************************************************************************************************
     * Static public functions
     ******************************************************************************************************************/

	reqText: function(id,title) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
		var req = {
				 url: '/res/html/' + id + '/' + T.languageId + '.html',
				callback: this.resp,
				scope: this
			};

		Ext.get("detail-header-title").update(title);
			// call the ajax request to get the data
		Ext.Ajax.request(req);
			
    
    },
	resp: function(options, success, response) {
		
			var msg, title;
		
			if (success) {
				J.fc.controller.view.body.update(response.responseText);
				J.fc.scrollToMember('zone-content-'+J.fc.controller.id);
			}
			
		}
});


J.Model.Artist =function(p){ 
	
	p = p ? p : {};
	
	 J.Model.Artist.superclass.constructor.call(this,p);

	    this.recordType = J.Record.Artist;
	    this.recordId = "artistId";
		
		
};

Ext.extend( J.Model.Artist , J.Model.BaseModel, {
	
	/***********************************************************************************************************************************************************
     * Static public functions
     **********************************************************************************************************************************************************/
    /***********************************************************************************************************************************************************
     * Public functions
     **********************************************************************************************************************************************************/
	getSummary : function(){
	
		return this.getField("biography").summary;
	
	},
	
	getPictureUrl: function(size) {
        return String.format("{0}/artist/{1}/{2}.jpg", J.MEDIAPATH, size, this.controller.id);
    },
    
    getTracksStore: function() {
		
		this.trackList = new Ext.data.Store({		
				remoteSort:true,
				reader: new Ext.data.JsonReader({
					root: "page",
					id: 'trackId',
					totalProperty: "total"
				}, J.Record.Track),
				baseParams: {
					artistId: this.controller.id
				},
				url: 'artist/tracks'
			});
		
        return this.trackList;
    },
	

	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 'r',
					artistId: this.controller.id
				},
			url: 'artist/comments'
	    });
	
        return this.CommentsStore;
    },
	
	getSubscribersStore: function() {

		 this.SubscribersStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.User),
				baseParams: {
			artistId: this.controller.id
				},
		url: 'artist/subscribers'
	    });
	
        return this.SubscribersStore;
    },

  
	getSuggestionsStore: function(){
		 this.SuggestionStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
	            id: "trackId"
	        }, J.Record.Suggestion),
				baseParams: {
			artistId: this.controller.id
				},
		url: 'artist/suggestions'
	    });		
		
		return this.SuggestionStore;
	 },
	
	getAlbumsStore :function(){
	
		this.AlbumsStore = new Ext.data.Store({
				reader: new Ext.data.JsonReader({
					root: "page",
					id: 'albumId',
					totalProperty: "total"
				}, J.Record.Album),
				baseParams: {
					artistId: this.controller.id
				},
				url: 'artist/albums'
			});
		
		return this.AlbumsStore;
		
	},
	
		getArtistsStore: function() {

		 this.ArtistStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "artistId"
	        }, J.Record.Artist),
				baseParams: {
			artistId: this.controller.id
				},
		url: 'artist/similarsartists'
	    });
	
        return this.ArtistsStore;
    },
    
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/artist/details",
            params: {
                artistId: this.controller.id,
                languageId: T.languageId
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data);
                }
            }
        }, p);
    },
	
	reqBiography: function(body) {
		
		var summary = this.getSummary();
		
        return this.jwRequest({
            url: "/artist/biography",
            params: {
                artistId: this.controller.id,
                languageId: T.languageId
            },
            callback: function(success, data) {
                if (success) {
					
					
					if(summary){
						if(summary.lentgh >data.text.lentgh){
						body.update(summary);
						}else{
							body.update(data.text);
						}
					}else if(data.text){
						body.update(data.text);
					}else{
						body.update("?");
					}
					
                   
					
                }
            }
        }, {});
    },
     reqSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/artist/subscribe",
            params: {
                artistId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg("Cet Artiste fait maintenant parti de vos abonnements");
					J.me.updateArtistSubscriptionsTreeRoot(data.artists);
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('unsubscribe'));
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	reqUnSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/artist/unsubscribe",
            params: {
                artistId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg("Cet Artiste a été retiré de vos abonnements");
					J.me.updateArtistSubscriptionsTreeRoot(data.artists);
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('subscribe'));
					}
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
    /***********************************************************************************************************************************************************
     * Private functions
     **********************************************************************************************************************************************************/
    update: function(data) {
        if (!data) {
            data = {};
        }
        if (data.artist) {
            this.updateRecord(data.artist);
        }

    }
    
    /***********************************************************************************************************************************************************
     * Handlers
     **********************************************************************************************************************************************************/
});
J.Model.Album =function(p){ 
	
		p = p ? p : {};
		J.Model.Album.superclass.constructor.call(this,p);

	    this.recordType = J.Record.Album;
	    this.recordId = "albumId";
	
};

Ext.extend( J.Model.Album  ,J.Model.BaseModel, {
  	 /***********************************************************************************************************************************************************
     * Static public functions
     **********************************************************************************************************************************************************/
    /***********************************************************************************************************************************************************
     * Public functions
     **********************************************************************************************************************************************************/
    getPictureUrl: function(size) {
        return String.format("{0}/album/{1}/{2}.jpg", J.MEDIAPATH, size, this.controller.id);
    },
    
    getTracksStore: function() {
		
		this.trackList = new Ext.data.Store({
			remoteSort:true,		
			reader: new Ext.data.JsonReader({
					root: "page",
					id:'trackId',
					
					totalProperty: "total"
			}, J.Record.Track),			
			baseParams :{
				albumId: this.controller.id
			},
			url: 'album/tracks'
		});
		
        return this.trackList;
    },
	

	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 'l',
					albumId: this.controller.id
				},
			url: 'album/comments'
	    });
	
        return this.CommentsStore;
    },
	
	getSubscribersStore: function() {

		 this.SubscribersStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.User),
				baseParams: {
			albumId: this.controller.id
				},
		url: 'album/subscribers'
	    });
	
        return this.SubscribersStore;
    },
    
	getArtistsStore: function() {

		 this.ArtistStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.Artist),
				baseParams: {
			albumId: this.controller.id
				},
		url: 'album/artists'
	    });
	
        return this.ArtistsStore;
    },
    
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/album/details",
            params: {
                albumId: this.controller.id,
                languageId: T.languageId,
				inc :'artists'
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data.album);
                }
            }
        }, p);
    },
    
	reqRecommendate : function(id){
		
	},
	reqUnrecommendate : function(id){
		
	},
	reqHide: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/setdisplay",
            params: {
                albumId: id,
				status: 1
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("album_is_hidden"));
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					
										
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	reqShow: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/setdisplay",
            params: {
                albumId: id,
				status: 0
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("album_is_shown"));
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
    reqRestrict: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/setrestriction",
            params: {
                albumId: id,
				status: 1
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("album_is_restrict"));
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
    reqAllow: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/setrestriction",
            params: {
                albumId: id,
				status: 0
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("album_is_allow"));
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
    reqSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/subscribe",
            params: {
                albumId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("album_is_add"));
					J.me.getAlbumsStore().loadData(data.albums);
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					
					var msg = Ext.get('item-subscribe-'+id);
					
				
					if(msg){
						msg.update(tr('unsubscribe'));
					}
					
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	reqUnSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/album/unsubscribe",
            params: {
                albumId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr('album_is_deleted'));
					J.me.getAlbumsStore().loadData(data.albums);
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest(true);
					}
					
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('subscribe'));
					}
					
					J.fc.refreshAction();
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        });
    },
    /***********************************************************************************************************************************************************
     * Handlers
     **********************************************************************************************************************************************************/
	setDisplay: function(status) {
        return this.jwRequest({
            url: "/album/setdisplay",
            params: {
                albumId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.album);
                }
            }
        });
    },
    setRestrict: function(status) {
        return this.jwRequest({
            url: "/album/setrestriction",
            params: {
                albumId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.album);
                }
            }
        });
    },
	setRecommendate: function(status) {
		return this.jwRequest({
            url: "/album/setRecommendate",
            params: {
                albumId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.album);
                }
            }
        });
	}
});
J.Model.Playlist =function(p){ 
		p = p ? p : {};
		J.Model.Playlist.superclass.constructor.call(this,p);
    
	    this.recordType = J.Record.Playlist;
	    this.recordId = "playlistId";
	

};

Ext.extend( J.Model.Playlist , J.Model.BaseModel, {
  	 /*******************************************************************************************************************
     * Static public functions
     ******************************************************************************************************************/
    /*******************************************************************************************************************
     * Public functions
     ******************************************************************************************************************/
    getPictureUrl: function(size) {
        return String.format("{0}/playlist/{1}/{2}.jpg", J.MEDIAPATH, size,this.controller.id);
    },
 	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 'p',
					playlistId: this.controller.id
				},
			url: 'playlist/comments'
	    });
	
        return this.CommentsStore;
    },
	
	getSubscribersStore: function() {

		 this.SubscribersStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.User),
				baseParams: {
			playlistId: this.controller.id
				},
		url: 'playlist/subscribers'
	    });
	
        return this.SubscribersStore;
    },
   getTracksStore: function() {
		
		this.TrackStore= new Ext.data.Store({		
			remoteSort:true,
			reader: new Ext.data.JsonReader({
					root: "page",
					id:'trackId',					
					totalProperty: "total"
			}, J.Record.Track),			
			baseParams :{
				playlistId: this.controller.id
			},
			url: 'playlist/tracks',
			listeners:{
				'load':function(store ,records, options){
				/*			if(!J.fc.controller.mine() && store.loaded != true){
								var timedate = new Date();
								var hour = timedate.getHours();
								var minutes = timedate.getMinutes();
								var playlistDuration = store.totalLength * 4 ;
								var time = minutes + hour*60;
								var position = parseInt((time % playlistDuration )/4);
								
					
							var record =store.getAt(position);
							var next1 =store.getAt(position+1);
							var next2 = store.getAt(position+2);
							
								if(!record){
								record ={
									record:{}
								};
							}
							
							if(!next1){
								next1 ={
									data:{}
								};
							};
							if(!next2){
								next2 ={
									data:{}
								};
							};
							
							
		var data = [];
		
        store.removeAll();
		
						// Current
				        data.push({
				            songId: -2,
							songName: "<div class='player-track-title'>On Air</div>",
				        "trackId":-2,"artistId":-2,"artistName":"","secArtistsNames":null,"albumId":-2,"albumName":"","songPopularity":-2,"itunesTrackUrl":null,"sourceId":null,"territory":null,"playlistTrackId":0,"trackPosition":0});
				        data.push(record.data);
				     
						// Current
				        data.push({
				            songId: -3,
							songName: "<div class='player-track-title'>"+tr('tracks_coming')+"</div>"
				        });
						
				       data = data.concat([next1.data,next2.data]);
					   store.loaded =true;
					   store.loadData({
					   	total : data.lentgh,
						page:data});
						
					}
				*/
				}
			}
		});
		this.TrackStore.loaded =false;
		
        return this.TrackStore;
    },
	/*******************************************************************************************************************
     * Public actions
     ******************************************************************************************************************/

    reqAddTracks: function(p) {
        if (!p.params) {
            p.params = {};
        }
        //p.params.tracksIds = "15";
        return this.jwRequest({
            url: "/playlist/addTracks",
            params: {
                playlistId: this.controller.id
            },
			scope: this,
            callback: function(success, data) {
                if (data.success) {
					this.tracks.insertTracks(data.playlistsTracks, data.insertPosition);
                }
            }
        }, p);
    },
    
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/playlist/details",
            params: {
                playlistId: this.controller.id
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data.playlist);
                }
            }
        }, p);
    },
    reqSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}

        return this.jwRequest({
            url: "/playlist/subscribe",
            params: {
                playlistId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("playlist_is_added"));
					J.me.updatePlaylistSubscriptionsTreeRoot(data.favoriteplaylists);
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest(true);
					}
					
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('unsubscribe'));
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        },{});
    },
	
	reqUnSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/playlist/unsubscribe",
            params: {
                playlistId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("playlist_is_deleted"));
					J.me.updatePlaylistSubscriptionsTreeRoot(data.favoriteplaylists);
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('subscribe'));
					}
					
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        },{});
    },
	
	
	reqDelete: function(id) {
		
		if(id){
			var idToDelete = id;
		}else{
			var idToDelete = this.controller.id;
		}
		
		var name = this.getField('playlistName');
		
        return this.jwRequest({
            url: "/playlist/delete",
            params: {
                playlistId: idToDelete
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		if (name) {
						J.InfoBox.msg(jTr('playlist_removed', name));
					}
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}
					
					if('user' == J.fc.controller.baseUrl){
						J.fc.jList.store.reload();
					}
					J.me.updatePlaylistTreeRoot(data.myplaylists);
					J.fc.gotoUrl('user', J.me.userId, 'playlists');
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	setRecommendate: function(status) {
		return this.jwRequest({
            url: "/playlist/setRecommendate",
            params: {
                playlistId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.playlist);
                }
            }
        });
	}
});

J.Model.News =function(p){ 
	
	p = p ? p : {};
	
	J.Model.News.superclass.constructor.call(this,p);
	this.recordType = J.Record.News;
	this.recordId = "newsId";
			
};

Ext.extend( J.Model.News , J.Model.BaseModel, {
	
	getPictureUrl: function(size) {
        return String.format("{0}/news/{1}/{2}.jpg", J.MEDIAPATH, size, this.controller.id);
    },

	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 'n',
					newsId: this.controller.id
				},
			url: 'news/comments'
	    });
	
        return this.CommentsStore;
    },
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/news/details",
            params: {
                newsId: this.controller.id,
                languageId: T.languageId
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data.news);
                }
            }
        }, p);
    },
	
	reqDelete: function(id,store) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/news/delete",
            params: {
                newsId: id
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		J.InfoBox.msg("news supprimée");
					if (store) {
						store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	
	reqReject: function(id,store) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/news/reject",
            params: {
                newsId: id
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		J.InfoBox.msg("news rejeté");
					
					if (store) {
						store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	
	reqValidate: function(id,store) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/news/validate",
            params: {
                newsId: id
            },
            callback: function(success, data) {
            	if(success == true ){
					
						J.InfoBox.msg("news validée");
					if (store) {
						store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        },{});
    }
});J.Model.Station =function(p){ 
	
		p = p ? p : {};
		J.Model.Station.superclass.constructor.call(this,p);

	    this.recordType = J.Record.Radio;
	    this.recordId = "radioId";
		this.url ="radio";
	
};

Ext.extend( J.Model.Station  ,J.Model.BaseModel, {
	 /***********************************************************************************************************************************************************
     * Static public functions
     **********************************************************************************************************************************************************/
    /***********************************************************************************************************************************************************
     * Public functions
     **********************************************************************************************************************************************************/
    getPictureUrl: function(size) {
        return String.format("{0}/radio/{1}/{2}.jpg", J.MEDIAPATH, size, this.controller.id);
    },
	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 'v',
					radioId: this.controller.id
				},
			url: 'radio/comments'
	    });
	
        return this.CommentsStore;
    },
	
	getSubscribersStore: function() {

		 this.SubscribersStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.User),
				baseParams: {
			radioId: this.controller.id
				},
		url: 'radio/subscribers'
	    });
	
        return this.SubscribersStore;
    },
    
	getArtistsStore: function() {

		 this.ArtistStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "userId"
	        }, J.Record.Artist),
				baseParams: {
			radioId: this.controller.id
				},
		url: 'radio/artists'
	    });
	
        return this.ArtistsStore;
    },
    
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/radio/details",
            params: {
                radioId: this.controller.id,
                languageId: T.languageId
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data.radio);
                }
            }
        }, p);
    },
    
      reqSubscribe: function(id) {
	  	
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/radio/subscribe",
            params: {
                radioId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("radio_is_added"));
					J.me.updateRadioSubscriptionsTreeRoot(data.radios);
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('unsubscribe'));
					}
					
					var spot = Ext.get('spot-subscribe-'+id);
					
					if(spot){
						spot.update(tr('unsubscribe'));
					}
				
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
				
				
            }
        }, {});
    },
	reqUnSubscribe: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
        return this.jwRequest({
            url: "/radio/unsubscribe",
            params: {
                radioId: id
            },
            callback: function(success, data) {
            	if(success == true ){
            		J.InfoBox.msg(tr("radio_is_deleted"));
					J.me.updateRadioSubscriptionsTreeRoot(data.radios);
					var msg = Ext.get('item-subscribe-'+id);
					
					if(msg){
						msg.update(tr('subscribe'));
					}
					
					var spot = Ext.get('spot-subscribe-'+id);
					
					if(spot){
						spot.update(tr('subscribe'));
					}
					
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    }
    /***********************************************************************************************************************************************************
     * Handlers
     **********************************************************************************************************************************************************/
});
J.Model.User = function(p){

    J.Model.User.superclass.constructor.call(this, p);
    
    this.recordType = J.Record.User;
    this.recordId = "userId";
    
};

Ext.extend(J.Model.User, J.Model.BaseModel, {

    /***************************************************************************
     * Public functions
     **************************************************************************/
  
	getPictureUrl: function(size) {
        return String.format("{0}/user/{1}/{2}.jpg", J.MEDIAPATH, size, this.getField("userPicture"));
    },
    
    
    getCommentsStore: function(){
    
        this.CommentsStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total"
            }, J.Record.Comment),
            baseParams: {
                objId: this.controller.id,
                objType: 'j',
                userId: this.controller.id
            },
            url: 'user/comments'
        });
        
        return this.CommentsStore;
    },
    
    getSubscribersStore: function(){
    
        this.SubscribersStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "userId"
            }, J.Record.User),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/subscribers'
        });
        
        return this.SubscribersStore;
    },
    
    
    getRadiosStore: function(){
    
        this.RadiosStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "radioId"
            }, J.Record.Radio),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/radios'
        });
        
        return this.RadiosStore;
    },
    getAngelsStore: function(){
        this.AngelStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "userId"
            }, J.Record.User),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/angels'
        });
        
        
        return this.AngelStore;
    },
    getPlaylistsStore: function(){
    
    
        this.playlistsStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "playlistId"
            }, J.Record.Playlist),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/playlists'
        });
        
        return this.playlistsStore;
    },
    getFavoritePlaylistsStore: function(){
    
    
        this.favoritePlaylistsStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "playlistId"
            }, J.Record.FavoritePlaylist),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/favoriteplaylists'
        });
        
        
        return this.favoritePlaylistsStore;
    },
    
    getAlbumsStore: function(directAccess){
    
        if (directAccess == undefined) {
            directAccess = false;
        }
        else {
            directAccess = true;
        }
        if (directAccess) {
            return new Ext.data.Store({ 
				remoteSort: true,
                reader: new Ext.data.JsonReader({
                    root: "page",
                    totalProperty: "total",
                    id: "albumId"
                }, J.Record.Album),
                baseParams: {
                    userId: this.controller.id
                },
                url: 'user/albums'
            });
        }
        this.AlbumsStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "albumId"
            }, J.Record.Album),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/albums'
        });
        
        return this.AlbumsStore;
    },
    getArtistsStore: function(){
        this.ArtistsStore = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "artistId"
            }, J.Record.Artist),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/artists'
        });
        
        return this.ArtistsStore;
    },
    getSuggestionsStore: function(){
        this.SuggestionStore = new Ext.data.Store({
        
            remoteSort: true,
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "trackId"
            }, J.Record.Suggestion),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/suggestions'
        });
        
        return this.SuggestionStore;
    },
    
    getOthersSuggestionsStore: function(){
    
        this.OthersSuggestionStore = new Ext.data.Store({
        
            remoteSort: true,
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "trackId"
            }, J.Record.Suggestion),
            baseParams: {
                userId: this.controller.id
            },
            url: 'user/otherssuggestions'
        });
        
        return this.OthersSuggestionStore;
        
    },
    
    
    
    reqSubscribe: function(id){
    
        if (id == undefined) {
            id = this.controller.id;
        }
        
        return this.jwRequest({
            url: "/user/subscribe",
            params: {
                angelId: id
            },
            callback: function(success, data){
            
                if (success == true) {
                    J.InfoBox.msg(tr("angel_is_added"));
                    J.me.updateAngelSubscriptionsTreeRoot(data.angels);
                    
                    if (J.fc.multipleRequest.length > 0) {
                        J.fc.execNextRequest();
                    }
                    if ('user' == J.fc.controller.baseUrl) {
                        J.fc.jList.store.reload();
                    }
                    
                    var msg = Ext.get('item-subscribe-' + id);
                    
                    if (msg) {
                        msg.update(tr('unsubscribe'));
                    }
                    
                }
                else {
					 J.InfoBox.msg(tr('ERR__ERROR'));
                }
            }
        }, {});
    },
	validGame: function(code){
    
	Ext.MessageBox.wait(tr("popup_msg_wait"));
        
        return this.jwRequest({
            url: "/game/check",
            params: {
                code: code
            },
            callback: function(success,data){
            	
				if (success = true) {
					
					if (data.success) {
						if (data.win == true) {
						
							this.controller.registerWinner(data.code);
							
						}
						else {
							Ext.Msg.alert('Merci de votre participation', "Désolé, vous n'avez malheureusement pas gagné cette fois mais n'hésitez pas à retenter votre chance," +
							"<br/>les gagnants sont nombreux sur Jiwa !<br/>" +
							"Il reste " +
							data.pos +
							" codes pour gagner un iPad");
						}
						
					}else{
						Ext.Msg.alert('Erreur', data.errors.error);
					}
					
				}
            }
        }, {});
    },
    reqUnSubscribe: function(id){
    
        if (id == undefined) {
            id = this.controller.id;
        }
        
        return this.jwRequest({
            url: "/user/unsubscribe",
            params: {
                angelId: id
            },
            callback: function(success, data){
                if (success == true) {
                    J.InfoBox.msg(tr("angel_is_deleted"));
                    J.me.updateAngelSubscriptionsTreeRoot(data.angels);
                    
                    if (J.fc.multipleRequest.length > 0) {
                        J.fc.execNextRequest();
                    }
                    if ('user' == J.fc.controller.baseUrl) {
                        J.fc.jList.store.reload();
                    }
                    
                    var msg = Ext.get('item-subscribe-' + id);
                    
                    if (msg) {
                        msg.update(tr('subscribe'));
                    }
                }
                else {
                    J.InfoBox.msg(tr('ERR__ERROR'));
                }
            }
        }, {});
    },
   /* 
    getFriendList: function(type){
       // type = connected, all, disconnected
        // openfire
         
        return this.jwRequest({
            url: "/user/getFriendListConnected",
            params: {
                limitFriends: 10
            },
            callback: function(success, data){
            
                if (success == true) {
                    J.fc.getController('account', true).view.refreshFriendList(data);
                }
                else {
                    J.InfoBox.msg(tr('ERR__ERROR'));
                }
            }
        }, {});
    },*/
    
    
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p){
        return this.jwRequest({
            url: "/user/details",
            params: {
                userId: this.controller.id,
                languageId: T.languageId,
				inc :'topcard'
            },
            callback: function(success, data){
                if (success) {
                    this.update(data.user);
                }
            }
        }, p);
    },
	setRecommendate: function(status) {
		return this.jwRequest({
            url: "/user/setRecommendate",
            params: {
                userId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.user);
                }
            }
        });
	},
	delMySuggestions: function(objToDelete){
		
        return this.jwRequest({
            url: "/user/delsuggestions",
             params: {
                id: objToDelete.id,
				trackId: objToDelete.trackId,
				lastOccurancy: objToDelete.lastOccurancy
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		if (J.fc.name) {
						J.InfoBox.msg(jTr('mySuggestion_removed', J.fc.name));
					}
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}else{
						J.fc.store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
    delOtherSuggestions: function(objToDelete){
		console.log(objToDelete);
        return this.jwRequest({
            url: "/user/delothersuggestions",
            params: {
                id: objToDelete.id,
				trackId: objToDelete.trackId,
				lastOccurancy: objToDelete.lastOccurancy
            },
            callback: function(success, data) {
            	if(success == true ){
					
            		if (J.fc.name) {
						J.InfoBox.msg(jTr('otherSuggestion_removed', J.fc.name));
					}
					
					if (J.fc.multipleRequest.length > 0) {
						J.fc.execNextRequest();
					}else{
						 J.fc.store.reload();
					}
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    },
	reqDelete: function() {
		

		var name = this.getField('userName');
		
        return this.jwRequest({
            url: "/user/delete",
            callback: function(success, data) {
            	if(success == true ){
					
            		if (name) {
						J.InfoBox.msg(jTr('user_removed', name));
					}
					
					J.acc.logout();
					
					
            	}else{
            		J.InfoBox.msg(tr('ERR__ERROR'));
            	}
            }
        }, {});
    }
});

J.Model.Track =function(p){ 
	
	p = p ? p : {};
	J.Model.Track.superclass.constructor.call(this, p);
    
    this.recordType = J.Record.Track;
    this.recordId = "trackId";
	
};


Ext.extend( J.Model.Track, J.Model.BaseModel, {
  	 /***********************************************************************************************************************************************************
     * Static public functions
     **********************************************************************************************************************************************************/
    /***********************************************************************************************************************************************************
     * Public functions
     **********************************************************************************************************************************************************/
    getPictureUrl: function(size) {
        return String.format("{0}/album/{1}/{2}.jpg", J.MEDIAPATH, size, this.record.data.albumId);
    },
    
	getCommentsStore: function() {

		 this.CommentsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Comment),
				baseParams: {
					objId: this.controller.id,
					objType: 's',
					trackId: this.controller.id
				},
			url: 'track/comments'
	    });
	
        return this.CommentsStore;
    },
	
    getPlaylistsStore: function() {
			
	    this.playlistsStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
	            id: "playlistId"
	        }, J.Record.Playlist),
				baseParams: {
			trackId: this.controller.id
				},
		url: 'track/playlists'
	    });
	
        return this.playlistsStore;
    },
    

	getSuggestionsStore: function(){
		 this.SuggestionStore = new Ext.data.Store({
	        reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total"
	        }, J.Record.Suggestion),
				baseParams: {
			trackId: this.controller.id
				},
		url: 'track/suggestions'
	    });		
		
		return this.SuggestionStore;
	 },
	
	getOthersSuggestionsStore: function(){
		
		this.OthersSuggestionStore = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "trackId"
			}, J.Record.Suggestion),
				baseParams: {
			trackId: this.controller.id
		},
		url: 'track/otherssuggestions'
		});
		
	return this.OthersSuggestionStore;
		
	},
    
    /***********************************************************************************************************************************************************
     * Public actions
     **********************************************************************************************************************************************************/
    reqDetails: function(p) {
        return this.jwRequest({
            url: "/track/details",
            params: {
                trackId: this.controller.id,
                languageId: T.languageId
            },
            callback: function(success, data) {
                if (success) {
                    this.update(data.track);
                }
            }
        });
    },
    /***********************************************************************************************************************************************************
     * Handlers
     **********************************************************************************************************************************************************/
	setDisplay: function(status) {
        return this.jwRequest({
            url: "/track/setdisplay",
            params: {
                trackId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.track);
                }
            }
        });
    },
    setRestrict: function(status) {
        return this.jwRequest({
            url: "/track/setrestriction",
            params: {
                trackId: this.controller.id,
				status: status
            },
            callback: function(success, data) {
                if (success) {
					this.update(data.edited.track);
                }
            }
        });
    }

});

J.Model.Account = function(p){

    p = p ? p : {};
    J.Model.Account.superclass.constructor.call(this, p);
    
    this.className = "Account";
    this.loggedIn = false;
    
    this.recordType = J.Record.User;
    this.recordId = "userId";
    
    J.me = this;
    
};




Ext.extend(J.Model.Account, J.Model.User, {

    /* ************************************************************************ *
     * Public functions
     * ************************************************************************ */
    isLoggedIn: function(){
        if (!this.loggedIn) {
            return false;
        }
        return true;
    },
    
    /* ************************************************************************ *
     * Public actions
     * ************************************************************************ */
    getPlaylistsRoot: function(){
    
        return this.playlistsRoot;
    }, 
	updateRadioSubscriptionsTreeRoot: function(radios){
    
        this.getRadiosStore().loadData(radios);
        
        var root = {
            text: tr("mainMenu-radio"),
            uiProvider: Ext.tree.TreeNodeUILeft,
            children: [],
            listeners: {
                scope: this,
                beforeexpand: function(){
                
                    if (this.artistSubscriptionsTreeNode) {
                        this.artistSubscriptionsTreeNode.collapse();
                    }
                    if (this.playlistSubscriptionsTreeNode) {
                        this.playlistSubscriptionsTreeNode.collapse();
                    }
                    if (this.radioSubscriptionsTreeNode) {
                        this.angelSubscriptionsTreeNode.collapse();
                    }
                    
                    this.controller.view.myPlayListContent.collapse(true);
                    
                }
            }
        
        };
        
        if (radios.page) {
        
            Ext.each(radios.page, function(item){
            
                var node = {
                    text: J.render.reduce(item.radioName, 18),
                    href: "#station/" + item.radioId + "/play",
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item account-radio",
                    leaf: true,
                    qtip: item.radioName
                };
                
                
                root.children.push(node);
                
            });
            
        }
        
        this.radioSubscriptionsTreeNode = new Ext.tree.AsyncTreeNode(root);
        
        this.controller.view.refreshRadioSubscriptionsList();
        
        
        J.fc.refreshAction();
        
        
    },
    updateArtistSubscriptionsTreeRoot: function(artists){
    
        this.getArtistsStore().loadData(artists);
        var root = {
            text: tr("artists"),
            uiProvider: Ext.tree.TreeNodeUILeft,
            children: [],
            listeners: {
                scope: this,
                beforeexpand: function(){
                
                    if (this.radioSubscriptionsTreeNode) {
                        this.radioSubscriptionsTreeNode.collapse();
                    }
                    if (this.playlistSubscriptionsTreeNode) {
                        this.playlistSubscriptionsTreeNode.collapse();
                    }
                    if (this.radioSubscriptionsTreeNode) {
                        this.angelSubscriptionsTreeNode.collapse();
                    }
                    
                    this.controller.view.myPlayListContent.collapse(true);
                    
                }
            }
        
        };
        
        
        if (artists.page) {
        
            Ext.each(artists.page, function(item){
            
                var node = {
                    text: J.render.reduce(item.artistName, 18),
                    href: "#artist/" + item.artistId,
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item account-artist",
                    leaf: true,
                    qtip: item.artistName
                };
                
                root.children.push(node);
                
            });
            
        }
        
        
        this.artistSubscriptionsTreeNode = new Ext.tree.AsyncTreeNode(root);
        
        this.controller.view.refreshArtistSubscriptionsList();
        
        J.fc.refreshAction();
    },
    
    updatePlaylistSubscriptionsTreeRoot: function(playlists){
    
        this.getFavoritePlaylistsStore().loadData(playlists);
        var root = {
            text: tr("searchBar_domain_playlist"),
            uiProvider: Ext.tree.TreeNodeUILeft,
            children: [],
            listeners: {
                scope: this,
                beforeexpand: function(){
                
                    if (this.radioSubscriptionsTreeNode) {
                        this.radioSubscriptionsTreeNode.collapse();
                    }
                    if (this.artistSubscriptionsTreeNode) {
                        this.artistSubscriptionsTreeNode.collapse();
                    }
                    if (this.radioSubscriptionsTreeNode) {
                        this.angelSubscriptionsTreeNode.collapse();
                    }
                    
                    this.controller.view.myPlayListContent.collapse(true);
                    
                }
            }
        
        };
        
        
        if (playlists.page) {
        
            Ext.each(playlists.page, function(item){
            
                var node = {
                    text: J.render.reduce(item.playlistName, 18),
                    href: "#playlist/" + item.playlistId,
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item account-playlist",
                    leaf: true,
                    qtip: item.playlistName
                };
                
                
                root.children.push(node);
                
            });
            
        }
        
        this.playlistSubscriptionsTreeNode = new Ext.tree.AsyncTreeNode(root);
        
        this.controller.view.refreshPlaylistSubscriptionsList();
        
        J.fc.refreshAction();
    },
    
    updateAngelSubscriptionsTreeRoot: function(angels){
    
        this.getAngelsStore().loadData(angels);
        
        var root = {
            text: tr("univers"),
            uiProvider: Ext.tree.TreeNodeUILeft,
            children: [],
            listeners: {
                scope: this,
                beforeexpand: function(){
                
                    if (this.radioSubscriptionsTreeNode) {
                        this.radioSubscriptionsTreeNode.collapse();
                    }
                    if (this.artistSubscriptionsTreeNode) {
                        this.artistSubscriptionsTreeNode.collapse();
                    }
                    if (this.playlistSubscriptionsTreeNode) {
                        this.playlistSubscriptionsTreeNode.collapse();
                    }
                    
                    this.controller.view.myPlayListContent.collapse(true);
                    
                }
            }
        
        };
        
        
        if (angels.page) {
        
            Ext.each(angels.page, function(item){
            
                var node = {
                    text: J.render.reduce(item.userName, 18),
                    href: "#user/" + item.userId,
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item account-angel",
                    leaf: true,
                    qtip: item.userName
                };
                
                root.children.push(node);
                
            });
            
        }
        
        this.angelSubscriptionsTreeNode = new Ext.tree.AsyncTreeNode(root);
        
        this.controller.view.refreshAngelSubscriptionsList();
        
        J.fc.refreshAction();
    },
    getPlaylistsStore: function(){
    
    
        this.playlistsStore = new Ext.data.GroupingStore({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total",
                id: "playlistId"
            }, J.Record.Playlist),
            baseParams: {
                userId: this.controller.id
            },
            sortInfo: {
                field: 'playlistFolder',
                direction: "ASC"
            },
            url: 'user/myplaylists',
            groupField: 'playlistFolder'
        });
        
        return this.playlistsStore;
    },
    updatePlaylistTreeRoot: function(playlists){
    
        this.getPlaylistsStore().loadData(playlists);
        
        var root = {
            text: tr("searchBar_domain_playlist"),
            draggable: false,
            children: []
        };
        
        var list = {
            text: tr("searchBar_domain_playlist"),
            draggable: false,
            children: []
        };
        
        
        if (playlists.page) {
        
            folder = {};
            folder.list = [];
            folder.root = [];
            
            
            
            Ext.each(playlists.page, function(item){
                var node = {
                    text: J.render.reduce(item.playlistName, 17),
                    href: "#playlist/" + item.playlistId,
                    iconCls: "account-item-img",
                    cls: "account-item account-playlist",
                    leaf: true,
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    qtip: item.playlistName
                };
                
                var leaf = {
                    text: item.playlistName,
                    id: item.playlistId,
                    leaf: true
                };
                
                if (item.playlistFolder == '') {
                
                    root.children.push(node);
                    list.children.push(leaf);
                }
                
            });
            
            
            Ext.each(playlists.page, function(item){
                var node = {
                    text: J.render.reduce(item.playlistName, 17),
                    href: "#playlist/" + item.playlistId,
                    iconCls: "account-item-img",
                    cls: "account-item account-playlist",
                    leaf: true,
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    qtip: item.playlistName
                };
                
                var leaf = {
                    text: item.playlistName,
                    id: item.playlistId,
                    leaf: true
                };
                
                if (item.playlistFolder != '' && item.playlistFolder != null) {
                
                    if (!folder.root[item.playlistFolder]) {
                    
                        folder.root[item.playlistFolder] = {
                            text: J.render.reduce(item.playlistFolder, 20),
                            uiProvider: Ext.tree.TreeNodeUILeft,
                            children: []
                        };
                        
                        folder.list[item.playlistFolder] = {
                            text: item.playlistFolder,
                            draggable: false,
                            children: []
                        };
                        
                        
                        root.children.push(folder.root[item.playlistFolder]);
                        
                        
                        list.children.push(folder.list[item.playlistFolder]);
                        
                    }
                    
                    folder.root[item.playlistFolder].children.push(node);
                    folder.list[item.playlistFolder].children.push(leaf);
                    
                }
                
            });
            
            
            
        }
        
        this.playlistsRoot = list;
        
        this.playlistsTreeNode = new Ext.tree.AsyncTreeNode(root);
        
        this.controller.view.refreshPlaylistsList();
        
        J.fc.refreshAction();
        
    },
	updatePlaylistPosition:function(param){
		 return this.jwRequest({
            url: '/user/playlistposition',
            params: {
				playlistId:param.playlistId,
				position:param.position,
				parentNode:param.parentNode
            },
            callback: function(success, data){
            
                if (success) {
					console.log("##### UPDATE SUCCESFULL ####");
                }
            }
            
        });
	},
    getMailStore: function(){
    
        this.MailsStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/user/inboxlist'
            }),
            
            reader: new Ext.data.JsonReader({
                root: 'page',
                totalProperty: 'total',
                id: 'inMailId'
            }, J.Record.Mail)
        });
        
        
        return this.MailsStore;
        
    },
    getMailSendsStore: function(){
    
        this.MailsStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/user/outboxlist'
            }),
            
            reader: new Ext.data.JsonReader({
                root: 'page',
                totalProperty: 'total',
                id: 'outMailId'
            }, J.Record.outMail)
        });
        
        
        return this.MailsStore;
        
    },
    getDonwloadsStore: function(){
    
        return new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                root: "page",
                totalProperty: "total"
            }, J.Record.Track),
            baseParams: {
                languageId: J.languageId,
                userId: J.me.userId
            },
            autoLoad: true,
            url: 'user/downloads'
        });
        
    },
    getReadMailStore: function(id){
    
        this.MailsStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/user/inboxget'
            }),
            baseParams: {
                inMailId: id
            },
            reader: new Ext.data.JsonReader({
                root: 'page',
                totalProperty: 'total',
                id: 'inMailId'
            }, J.Record.Mail)
        });
        
        return this.MailsStore;
        
    },
    getReadSendMailStore: function(id){
    
        this.MailsStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/user/outboxget'
            }),
            baseParams: {
                outMailId: id
            },
            reader: new Ext.data.JsonReader({
                root: 'page',
                totalProperty: 'total',
                id: 'outMailId'
            }, J.Record.outMail)
        });
        
        return this.MailsStore;
        
    },
    
    
    reqDeleteMail: function(p){
        return this.jwRequest({
            url: "/user/inboxdelete",
            params: p,
            scope: this,
            callback: function(success, data){
            
                if (success) {
                    J.fc.gotoUrl("account", "mails", 'inbox');
                    this.MailsStore.reload();
                }
                else {
                    Ext.MessageBox.alert(tr('mailBox_popup_deleteMail_title'), tr('mailBox_popup_deleteMail_error'));
                }
            }
            
        }, p);
    },
    
    reqCheckAuth: function(){
      J.fc.check= true;

 	return this.jwRequest({
            url: "/user/checkauth",
            callback: function(success, data){
				
					 
                if (success) {
                    this.reqReconnect(data);
                }
				J.fc.check= false;
				
            }
            
        });
        
    },
    reqReconnect: function(p){
        return this.jwRequest({
            url: '/user/reconnect',
            params: {
                inc: "artists+radios+myplaylists+favoritePlaylists+albums+angels",
                accountInfos: true
            },
            callback: function(success, data){
            
                if (success) {
                    this.loadAccount(data);
                    this.controller.check();
                }
                
            }
            
        }, p);
    },
    reqCheck: function(){
        return this.jwRequest({
            url: "/user/check",
            params: {                //inc: "getfriendlistconnected"                  
            },
            callback: function(success, data){
                if (success) {
                    this.controller.onCheck(data);
                    //this.controller.view.refreshFriendList(data.user.getfriendlistconnected);
                }
                
                var x = this;
                setTimeout(function(){
                    x.reqCheck();
                }, 60 * 1000);
                
            }
            
        });
        
    },
    
    reqCreate: function(p){
        return this.jwRequest({
            url: "/user/create",
            
            callback: function(success, data){
                if (success) {
                    this.updateData(data.user);
                }
            }
            
        }, p);
    },
    
    reqDelete: function(p){
        return this.jwRequest({
            url: "/user/delete",
            
            callback: function(success, data){
                if (success) {
                    this.loggedIn = false;
                }
            }
            
        }, p);
    },
    
    reqEdit: function(p){
        return this.jwRequest({
            url: "/user/edit",
            params: {
                userId: this.getData("userId")
            },
            callback: function(success, data){
                if (success) {
                    this.updateData(data.modifiedFields);
                }
            }
        }, p);
    },
    
    loadAccount: function(data){
    
        if (data) {
        
            this.loggedIn = true;
            
            
            if (data.user) {
				
				
				if(data.user.userId){
					this.update(data.user);
                
				
					if(J.fc.name =='account' || J.fc.name =='reset' ){
						 J.fc.dispatchUrl(J.fc.url);
	              
					}
				
					if(data.user.age){
						J.fc.PubProfile.age =data.user.age;
					}
					
					if(data.user.sex){
						J.fc.PubProfile.age =data.user.sex;
					}
				
					if(data.user.relationshipStatus){
						
						if(data.user.relationshipStatus == 's'){
							J.fc.PubProfile.social=true;
						}
						
					}
					
					if(data.user.supporter){
						
						J.CookieProvider.set("warner", "ok");
						
					}
					
					J.fc.getController('ad',true).getUpdateUrlList();
				
				
					if(J.fc.getController('player',true).logginPaused==true){
						J.fc.getController('player',true).jwResume();
					}
				
				}
                
                
            
            }
            
        }
        
        if (data.user.userId) {
            J.me.userId = data.user.userId;
        }
        else 
            if (data.userId) {
                J.me.userId = data.userId;
            }
        
        if (!data.user.radios) {
            data.user.radios = {
                page: [],
                total: 0
            };
        }
        
        if (!data.user.artists) {
            data.user.artists = {
                page: [],
                total: 0
            };
        }
        
        if (!data.user.angels) {
            data.user.angels = {
                page: [],
                total: 0
            };
        }
        
        if (!data.user.albums) {
            data.user.albums = {
                page: [],
                total: 0
            };
        }
        
        if (!data.user.favoriteplaylists) {
            data.user.favoriteplaylists = {
                page: [],
                total: 0
            };
        }
        
        if (!data.user.myplaylists) {
            data.user.myplaylists = {
                page: [],
                total: 0
            };
        }
        
        this.updatePlaylistTreeRoot(data.user.myplaylists);
        this.updatePlaylistSubscriptionsTreeRoot(data.user.favoriteplaylists);
        this.getAlbumsStore().loadData(data.user.albums);
        this.updateAngelSubscriptionsTreeRoot(data.user.angels);
        this.updateRadioSubscriptionsTreeRoot(data.user.radios);
        this.updateArtistSubscriptionsTreeRoot(data.user.artists);
        
        
        
        this.controller.view.refreshAccountButton();
        J.fc.refreshAction();
        
    },
    
    reqLogout: function(p){
    
        return this.jwRequest({
            url: "/user/logout",
            
            callback: function(success, data){
                if (success) {
                    this.loggedIn = false;
                    window.location.href = document.location.pathname;
                }
            }
            
        }, p);
    },
    
    reqRequestPassword: function(p){
        return this.jwRequest({
            url: "/user/requestPassword"
        }, p);
    },
    
    reqResetPassword: function(p){
        return this.jwRequest({
            url: "/user/resetPassword"
        }, p);
    }
    
    
});


J.Model.AdminNews =Ext.extend( J.Model.News, {
	/***************************************************************************
	 * Static public functions
	 **************************************************************************/
	getSearchStore: function(id) {

		this.store = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
	            root: "page",
				id: "newsId",
                totalProperty: "total"
	        }, J.Record.News),
			url: "/news/search",
			baseParams: {
				state:id
			},
			autoLoad:false
		});
			
        return this.store;
    }
});

/*******************************************************************************
 * Static functions
 ******************************************************************************/

J.Model.AdminBoxes =function(p){ 
		p = p ? p : {};
	    J.Model.AdminBoxes.superclass.constructor.call(this,p);
	    
	    this.data = new Ext.util.MixedCollection();
	    this.recordType = J.Record.Home;
	    this.recordId = "homeId";
	    this.key = 0;
};


//<iframe width="300" scrolling="no" height="250" frameborder="0" align="top" marginheight="0" marginwidth="0" src="/res/html/ads/FR-HP-300x250.html?v=2" name="ajaxAd2" id="ajaxAd2"/>

Ext.extend( J.Model.AdminBoxes,J.Model.BaseModel, {

    editBox: function(columnIndex, boxIndex, data) {
        this.data.itemAt(rowIndex).itemAt(columnIndex).itemAt(boxIndex).addAll(data);
    },
	getJson :function(){
		var nb = [];
		var json= this.controller.view.panel.getConfig();
		
		var data =Ext.encode(nb);
		return {
				homeId: this.getField('homeId'),
				content : Ext.encode(json),
				data : data
			};
	
	},
	reqSave: function(rowIndex, columnIndex, boxIndex) {
		
	
		
		if(this.getField('homeId') && this.getField('title')){
			
        return this.jwRequest({
         	  url: '/home/edit',
				params:this.getJson(),
            callback: function(success, data) {
            	if(success == true ){
						
						J.InfoBox.msg('Home mise à jour avec succés');
	            	}else{
	            		J.InfoBox.msg(tr('ERR__ERROR'));
	            	}
            }
        }, {});
   

		}else{
			J.InfoBox.msg('Cet Configuration n\'est pas dans notre base , merci d\'utiliser le button : "Enregistrer Sous"');
			
		}
	},
	reqReload: function(id) {
		
		if(id == undefined){
			id  = this.getField('homeId');
		}
		
		var model=this;
        return this.jwRequest({
            url: "/home/details",
            params: {
                homeId: id,
				languageId:J.languageId,
				withNews:true,
				doInvalidate:true
            },
            callback: function(success, data) {
						Ext.MessageBox.hide();
                if (success) {
					if(data.home){
						model.controller.view.render(data.home.content);
					}
                }else{
					J.InfoBox.msg('Erreur lors du chargement');
				}
			
            }
        }, {});
    },
	reqDetails: function(id) {
		
		if(id == undefined){
			id  = this.controller.id;
		}
		
		var model=this;
        return this.jwRequest({
            url: "/home/details",
            params: {
                homeId: id,
				languageId:J.languageId,
				withNews:true
            },
            callback: function(success, data) {
					
                if (success) {
					model.update(data);
					if(data.home){
						model.controller.view.render(data.home.content);
					}
                }else{
					model.controller.view.render(false);
				}
				Ext.MessageBox.hide();
            }
        }, {});
    },
	reqSelected: function(p) {
		
		var model=this;
        return this.jwRequest({
            url: "/home/selected",
            params: {
				languageId:J.languageId,
				withNews:true
            },
            callback: function(success, data) {
                if (success) {
					model.update(data);
					if(data.home){
						model.controller.view.render(data.home.content);
					}
                }else{
					model.controller.view.render(false);
				}
				Ext.MessageBox.hide();
            }
        }, {});
    },
	reqSelect: function(rowIndex, columnIndex, boxIndex) {
		
		var json = this.getJson();
		
		if(this.getField('homeId') && this.getField('title')){
			
			return this.jwRequest({
	         	  url: '/home/select',
					params: {
						homeId: this.getField('homeId'),
						languageId:J.languageId
				},
				
	            callback: function(success, data) {
	            	if(success == true ){
						J.InfoBox.msg('Home mise à jour avec succés');
	            	}else{
	            		J.InfoBox.msg(tr('ERR__ERROR'));
	            	}
	            }
	        }, {});
   
		}else{
			
			J.InfoBox.msg('Cet Configuration n\'est pas dans notre base , merci d\'utiliser le button : "Enregistrer Sous"');
		
		}
	},
	update: function(data) {
        if (!data) {
            data = {};
        }
		
        if (data) {
            this.updateRecord(data.home);
		 }
    }
	
});
J.Model.AdminTradTool =Ext.extend( J.Model.News, {
	/***************************************************************************
	 * Static public functions
	 **************************************************************************/
	getTranslations: function(id) {
		this.store = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
	            root: "page",
				id: "translationLabelId",
                totalProperty: "total"
	        }, J.Record.Translation),
			url: "/tool/translations",
			baseParams: {
				languageId : id
			},
			autoLoad:false
		});
			
        return this.store;
    },
	
	search: function(param){
		this.store = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
	            root: "page",
				id: "translationLabelId",
                totalProperty: "total"
	        }, J.Record.Translation),
			url: "/tool/translations",
			baseParams: {
				languageId : param.iLanguageId,
				searchLabel : param.sSearchLabel,
				searchTranslation : param.sSearchTranslation
			},
			autoLoad:false
		});
			
        return this.store;
		
	},
	
	reqValidate: function(){
		return this.jwRequest({
            url: "/tool/validatetranslation",
            callback: function(success, data) {
                if (success) {
                    this.controller.afterEdit();
                }
            }
        }, {});
	},
	
	reqDelete: function(param){
		return this.jwRequest({
            url: "/tool/deltranslation",
			params: {
				translationLabelId : param.translationLabelId,
				languageId : param.languageId
			},
            callback: function(success, data) {
                if (success) {
                    this.controller.afterEdit(data);
                }
            }
        }, {});
	}
});

/*******************************************************************************
 * Static functions
 ******************************************************************************/

J.Model.Last =Ext.extend( J.Model.BaseModel, {

	getStore: function() {

	if (!this.store) {
	
		this.store = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "albumId"
			}, J.Record.Album),
			url: 'album/last'
		});
	}
	
	return this.store;
    }
});



J.Model.Radio = Ext.extend(J.Model.BaseModel, {

	getRadiosStore: function(id) {

	if(J.RadiosStore){
		J.RadiosStore.clearFilter();
	}
		if (!J.RadiosStore) {
			J.RadiosStore = new Ext.data.Store({
				reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
					id: "radioUrl"
				}, J.Record.Radio),
				url: 'radio/getall',
				autoLoad:true,
				scope:this,
				listeners :{
					datachanged : function(store){
						
						if(id){
							
				var radio  = store.getById(id);
					if(radio){
						J.fc.getController("player", true).jwPlayRadio(radio.data.radioId, radio.data.radioName,'radio');
					}	
					
					}
					
					}
				}
					}
				);
		
			
			
		}else if(id){
				var radio  = J.RadiosStore.getById(id);
				if(radio){
							J.fc.getController("player", true).jwPlayRadio(radio.data.radioId, radio.data.radioName,'radio');
				}
		}
		
        return J.RadiosStore;
    },
	
	getTopRadiosStore: function(id) {

	
		if (!J.TopRadiosStore) {
			J.TopRadiosStore = new Ext.data.Store({
				reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
					id: "radioUrl"
				}, J.Record.Radio),
				url: 'radio/top',
				autoLoad:true,
				scope:this
					}
				);
		}
		
        return J.TopRadiosStore;
    }

});



J.Model.Top = Ext.extend( J.Model.BaseModel, {
  	 /*******************************************************************************************************************
     * Static public functions
     ******************************************************************************************************************/
	
	getTopSongsStore: function(id) {

		if (id ==undefined){
			id='all';
		}
		this.store = new Ext.data.Store({
					reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "trackId"
					}, J.Record.Track),
					url: 'track/top',
					baseParams: {
					theme:id
					},
					autoLoad:true
		});
			
        return this.store;
    },
	
	getTopUsersStore: function(id) {

		if (id ==undefined){
			id='all';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "userId"
						}, J.Record.User),
					url: 'user/top',
					baseParams: {
					theme:id
					},
					autoLoad:true
		});
			
        return this.store;
    },
		getTopAlbumsStore: function(id) {

		if (id ==undefined){
			id='all';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "albumId"
						}, J.Record.Album),
					url: 'album/top',
					baseParams: {
					theme:id
					},
					autoLoad:true
		});
			
        return this.store;
    },
			getTopArtistsStore: function(id) {

		if (id ==undefined){
			id='all';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "artistId"
						}, J.Record.Artist),
					url: 'artist/top',
					baseParams: {
					theme:id
					},
					autoLoad:true
		});
			
        return this.store;
    },
	
	getTopPlaylistsStore: function(id) {

		if (id ==undefined){
			id='all';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "playlistId"
						}, J.Record.Playlist),
					url: 'playlist/top',
					baseParams: {
					theme:id
			},
					autoLoad:true
		});
			
        return this.store;
    }
});


J.Model.Recommendation =Ext.extend( J.Model.BaseModel, {

	getStore: function() {

	if (!this.store) {
	
		this.store = new Ext.data.Store({
			reader: new Ext.data.JsonReader({
				root: "page",
				totalProperty: "total",
				id: "albumId"
			}, J.Record.Album),
			url: 'album/recommendations'
		});
	}
	
	return this.store;
    }
});



J.Model.Community = Ext.extend( J.Model.BaseModel, {
  	 /*******************************************************************************************************************
     * Static public functions
     ******************************************************************************************************************/

	getCommunitySongsStore: function(id) {

		this.store = new Ext.data.Store({
					reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "trackId"
					},  J.Record.Suggestion),
					url: 'track/community',
					autoLoad:true
		});
			
        return this.store;
    },
	
	getCommunityUsersStore: function(id) {

		if (id ==undefined){
			id='recommended';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "userId"
						}, J.Record.User),
					url: 'user/community',
					baseParams: {
					type:id
					},
					autoLoad:true
		});
			
        return this.store;
    },
	
	
	getCommunityPlaylistsStore: function(id) {

		if (id ==undefined){
			id='recommended';
		}
		this.store = new Ext.data.Store({
						reader: new Ext.data.JsonReader({
							root: "page",
							totalProperty: "total",
							id: "playlistId"
						}, J.Record.Playlist),
					url: 'playlist/community',
					baseParams: {
					type:id
			},
					autoLoad:true
		});
			
        return this.store;
    }
});


J.Controller.Base = function(){
};

J.Controller.Base.prototype = {
	/**
	 * Called once after the instantiation of each controller
	 */
	view :null,
	model : null,
	baseUrl:"",
	id:0,
	init :function(){;
	},
	refresh :function(){
		
	},
	refreshAction :function(){
		
	},
	mine: function() {
		return false;
	},
	isExportable: function() {
		return false;
	},
	/**
	 * Called before asking for a content filling.
	 */
	up: function() {
	
		
	},
	/**
	 * Called before asking for a content destroying
	 */
	downContent: function() {
		
	},
	down: function() {
		if (this.view) {
			this.view.destroy();
			this.view = null;
		}
		if (this.model) {
			this.model.destroy();
			this.model = null;
		}
	}
};

J.Controller.Card = Ext.extend(J.Controller.Base, {

    baseUrl: "",
    id: 0,
    startPlay: false,
    defaultCategory: null,
    defaultInc: null,
    up: function(){
    
        this.model = new J.Model.Card({
            controller: this
        });
        
        this.view = new J.View.Card({
            controller: this
        });
        
    },
    changeSub: function(id){
    
        if (id) {
        
            if (this.isFan(id)) {
            
                this.unsubscribe(id);
            }
            else {
                this.subscribe(id);
            }
            
        }
        
    },
    show: function(id, category, options){
    
        if (!this.view.rendered) {
            this.view.render();
        }
        this.wantPLay = false;
        if (this.id != id) {
        
            this.id = id;
            this.model.reqDetails();
            
        }
        else 
            if (this.model.record == undefined) {
                this.model.reqDetails();
            }
        
        if (J.fc.first == true) {
            Ext.MessageBox.wait(tr('popup_msg_wait'));
            
            var x = this;
            
            J.fc.play = function(){
                x.play();
            }
            
        }
        else 
            if (category == 'play') {
                this.wantPLay = true;
                J.fc.play = function(){
                }
                category = this.defaultCategory;
            }
        
        
        category = category || this.defaultCategory;
        
        
        
        /* Create view */
        
        
        this.renderBody(this.id, this.model, category);
		
		 this.view.refreshAction();
        
        this.view.rendered = true;
        
    },getAds: function(){
    
				var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=h&image=true&language="+J.Language.languageCode+"&urlContent="+url;
				
				return '<iframe  SRC="' + srcBan + '" WIDTH="100%"  height="70" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe>';
				
				
    
    },
    categoryChangeHandler: function(category){
        J.fc.gotoUrl(this.baseUrl, this.id, category);
    },
    refreshAction: function(){
        this.view.refreshAction();
    },
    renderBody: function(id, model, category){
        body = this.view.getContentBody();
        
		
        switch (category) {
        
            case "fullText":
                
                var text = body.createChild({
                    cls: "fulltext",
                    html: tr('popup_msg_wait')
                });
                
                this.model.reqBiography(text);
                break;
                
            case "subscribers":
                
                J.fc.grid = new J.View.UserGrid({
                    store: this.model.getSubscribersStore(),
                    renderTo: body
                });
                break;
                
            case "angels":
                
                J.fc.grid = new J.View.UserGrid({
                    store: this.model.getAngelsStore(),
                    renderTo: body
                });
                break;
                
            case "suggestions":
                
                if (this.baseUrl == 'track') {
                    var store = this.model.getSuggestionsStore()
                    J.fc.grid = new J.View.Suggestion({
                        store: store,
                        renderTo: body
                    });
                    store.load();
                }
                else {
                    J.fc.grid = new J.View.SuggestionGrid({
                        store: this.model.getSuggestionsStore(),
                        renderTo: body
                    });
                }
                break;
            case "othersSuggestions":
                
                J.fc.grid = new J.View.SuggestionGrid({
                    store: this.model.getOthersSuggestionsStore(),
                    renderTo: body
                });
                break;
                
            case "favoritesPlaylist":
                
                J.fc.grid = new J.View.FavoritePlaylistGrid({
                    store: this.model.getFavoritePlaylistsStore(),
                    renderTo: body
                });
                break;
            case "playlists":
                
                J.fc.grid = new J.View.PlaylistGrid({
                    store: this.model.getPlaylistsStore(),
                    renderTo: body
                });
                break;
            case "albums":
                
                J.fc.grid = new J.View.AlbumGrid({
                    store: this.model.getAlbumsStore(),
                    renderTo: body
                });
                break;
            case "tracks":
                var menu = [{
                    text: tr('addToPlaylist'),
                    handler: function(){
                        J.fc.grid.addToPlaylist(true);
                    }
                }];
                
                this.view.addAction(true);
                J.fc.grid = new J.View.TrackGrid({
                    store: this.model.getTracksStore(),
                    renderTo: body
                });
                break;
            case "comments":
                
                
                break;
                
        }
        
        this.commentController = new J.Controller.Comment({
            store: this.model.getCommentsStore(),
            renderTo: body
        });
        
        this.category = category;
		
        
    },
    refresh: function(){
    
        if (this.id > 0) {
        
        
            if (this.model) {
            
                if (J.fc.controller.baseUrl == this.baseUrl && J.fc.controller.id == this.id) {
                    /*
                     * A revoir pour track
                     */
					
					if(this.model.record){
                   if (this.model.record.data.hasPicture || this.baseUrl == "track") {
				   	this.view.setImage(this.model.getPictureUrl(this.view.imageSize));
				   }
				   else {
				   	if (this.baseUrl == "user") {
				   		this.view.setImage("/static/img/" + this.baseUrl + "/" + this.view.imageSize + "/" + this.model.record.data.sex + "default.jpg");
				   	}
				   	else {
				   		this.view.setImage("/static/img/" + this.baseUrl + "/" + this.view.imageSize + "/default.jpg");
				   	}
				   	
				   }
				
                    
                    this.view.setContent(this.model.record.data);
                    
                    if (this.view.setTopViewCard) {
                        this.view.setTopViewCard(this.model.record.data.topcard);
                    }
                    
                    this.view.setTitle(this.model.record.data);
                    
                 	}else{
						      this.view.setImage("/static/img/" + this.baseUrl + "/" + this.view.imageSize + "/default.jpg");
                      
					}
					   this.view.refreshAction();
                    
                    if (J.fc.playerReady) {
                        if (!J.fc.played && J.fc.first) {
                            J.fc.played = true;
                            this.play();
                        }
                        else 
                            if (this.wantPLay) {
                                this.play();
                            }
                        J.fc.played = true;
                    }
                    else {
                        if (!J.fc.played) {
                            var x = this;
                            J.fc.play = function(){
                                J.fc.played = true;
                                x.play();
                            }
                        }
                        
                    }
                    
                    
                }
                
            }
        }
        
    },
    updateDescription: function(id, div){
        //similar-artist-button # play-button # tools-button
        var text = this.updateTextCardDescription();
        switch (id) {
            case "similar-artist-button":
                div.update(text.similar);
                break;
            case "play-button":
                div.update(text.play);
                break;
            case "tools-button":
                div.update(text.tools);
                break;
            default:
                div.update('');
                break;
        }
    },
    actionHandler: function(id){
    
        J.track(this.baseUrl, id);
        
        switch (id) {
        
            case "subscribe":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.subscribe();
                }
                break;
                
            case "message":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.message();
                }
                break;
                
            case "unsubscribe":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.unsubscribe();
                }
                break;
                
                
            case "tools-button":
            case "edit-button":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.edit();
                }
                break;
                
            case "edit-rename":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.rename();
                }
                break;
                
            case "edit-picture":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.setPicture();
                }
                break;
			
			case "support-jiwa":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                   J.fc.getController('user', true).popupSupporter();
                }
             break;	
				
			case "edit-picture-focus":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.setPictureFocus();
                }
            break;
                
            case "edit-recommendation-check":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.setRecommendation();
                }
                break;
            case "buy":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.buy();
                }
                break;
				 case "edit-recommendation-uncheck":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.unsetRecommendation();
                }
                break;
                
            case "edit-delete":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.remove();
                }
                break;
                
            case "remove":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.remove();
                }
                break;
                
            case "suggest":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.suggest();
                }
                break;
                
                
            case "edit-genre":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.editGenre();
                }
                break;
                
            case "edit-tag":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.editTag();
                }
                break;
                
            case "hidden":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.hiddenElement();
                }
                break;
                
            case "display":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.displayElement();
                }
                break;
                
            case "edit-restriction":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.restrictElement();
                }
                break;
				
            case "signal":
                this.signal();
            break;
				    
            case "edit-not-restriction":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.allowElement();
                }
                break;   
                
                
            case "addToPlaylist":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.addToPlaylist();
                }
                break;
                
            case "addToNewPlaylist":
                if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
                }
                else {
                    this.addToNewPlaylist();
                }
                break;
                
        }
        
        switch (id) {
        
        
            case "download":
                this.download();
                break;
            case "similar-artist-button":
                this.similar();
                break;
                
            case "play":
            case "play-button":
                this.play();
                break;
                
            case "addToPlayer":
                this.addToPlayer();
                break;
                
            case "permalink":
                this.permalink();
                break;
                
                
            case "playerlink":
                this.playerlink();
                break;
                
            case "share":
                this.share();
                break;
        }
        
    },
    mine: function(){
        
    },
    isFan: function(){
        return false;
    },
    isHidden: function(){
        return false;
    },
    isRestricted: function(){
    	return false;
    },
    isRecommendate: function(){
        return false;
    },
    isDownload: function(){
        return false;
    },
    edit: function(){
    
    },
    play: function(){
    
    
    
    },
    subscribe: function(id){
        if (id == undefined) {
            id = this.id;
        }
        
        Ext.Msg.wait(tr('popup_msg_wait'));
        this.model.reqSubscribe(id);
    },
    signal : function(){
		J.Problem.show({objCls: J.fc.name, objId: J.fc.controller.id});
	},
    unsubscribe: function(id){
        if (id == undefined) {
            id = this.id;
        }
        Ext.Msg.wait(tr('popup_msg_wait'));
        this.model.reqUnSubscribe(id);
    },
    setPicture: function(){
    
    },
    message: function(){
    
    },
    remove: function(){
    
    },
    share: function(){
        J.Seo.init(this.model.record.data, this.baseUrl);
        J.Seo.share();
    },
    download: function(){
   
   
        if (this.model.record.data.itunesTrackUrl) {
            J.track('starzik', 'download');
            window.open(this.model.record.data.starzikTrackUrl, "Jiwa Download - Starzik", "");
        }else if (this.model.record.data.itunesTrackUrl) {
            J.track('itunes', 'download');
            window.open('http://clk.tradedoubler.com/click?p=23753&partnerId=2003&a=1570290&g=0&td_partnerId=2003&url=' + this.model.record.data.itunesTrackUrl + "", "Jiwa Download - Itunes", "");
        }
        else {
            J.InfoBox.msg("Ce morceau n'est pas encore disponible en télechargement");
        }
        
        
    },
    permalink: function(){
    
        J.Seo.init(this.model.record.data, this.baseUrl);
        
        var popup = new J.Popup({
            title: tr('link'),
            trackController: 'permalink',
            trackAction: this.baseUrl,
            big: true,
            fields: [{
                type: 'text',
                fieldLabel: '',
                style: 'width:500px',
                width: 600,
                hideLabel: true,
                value: J.Seo.url
            }],
            buttons: [{
                text: tr('popup_button_close'),
                handler: function(){
                    popup.win.close();
                }
            }]
        });
        
    },
    playerlink: function(){
    
        J.Seo.init(this.model.record.data, this.baseUrl);
        
        this.textDescription = new Ext.Panel({
            layout: 'column',
            renderTo: body,
            cls: "popup-player-link-text",
            border: false,
            items: [{
                width: 75,
                border: false,
                cls: "jGrid-illustration-wrapper",
                html: 'Text d\'explication pour le popup'
            }]
        });
        
        var popup = new J.Popup({
            title: tr('soe_player_exportable'),
            trackController: 'playerlink',
            trackAction: this.baseUrl,
            big: true,
            fields: [{
                type: 'textarea',
                fieldLabel: '',
                style: 'width:500px',
                width: 600,
                hideLabel: true,
                value: J.Seo.widget_code()
            }],
            buttons: [{
                text: tr('popup_button_close'),
                handler: function(){
                    popup.win.close();
                }
            }]
        });
        
    },
    widget: function(){
        //J.WizardSong.show({trackId:J.Seo.trackId, permalink : J.Seo.artistLink, name:J.Seo.artistName});
        J.WizardPlaylist.show({
            domain: this.baseUrl,
            id: this.id,
            name: this.model.getField(this.baseUrl + 'Name'),
            permalink: J.Seo.url
        });
    },
    SoeExtractInfo: function(){
        return {
            sUrlPermalink: J.Seo.url,
            sUrlPlayerlink: J.Seo.widget_code()
        };
    }
});

J.Controller.Categorie = Ext.extend( J.Controller.Base, {
	baseUrl : "",
	id : null,
	defaultCategory : null,	
	defaultInc :null,
	up: function(){
		if(!this.view.rendered){
				this.view.render();
				
		}
		this.view.rendered =true;
	},
	show: function(id) {
			this.id = id;
		

	},
	changeSub :function (id){
		
		if (id ) {
			if(this.isFan(id)){
				
				this.unsubscribe(id);
			}else{
				this.subscribe(id);
			}
		}
	
	},	
	subscribe :function (id){		
		Ext.Msg.wait(tr('popup_msg_wait'));
		this.model.reqSubscribe(id);
	},
	unsubscribe :function (id){		
		Ext.Msg.wait(tr('popup_msg_wait'));
		this.model.reqUnSubscribe(id);
	}
});

J.Controller.Ad = Ext.extend(J.Controller.Base, {
	change:false,
	comment: null,
	vertical: null,
	content : null,
	urlList : [	
	"www.musique.fr","www.concert.fr",
	"www.sfr.fr","www.megasonnerie.com",
	"www.toutgagner.com","www.cdiscount.com",
	"www.pixmania.com"],	
	task : {
				run : function() {
					
					if(!J.Ad.change ){													
						J.Ad.refresh();
						J.track('ad','music');
					}
					
					J.Ad.change = false;
					
				},
				interval : 60000			
		},
		
    init: function() {
        /* Create views */
		
		J.Ad =this;
		
        this.view = new Ext.util.MixedCollection();
        
	
        /* One by one init */
       this.addView({
            key: "headerMegaBanner",
            type: "megaBanner",
            renderTo: J.fc.getZone("adMegaBanner"),
            position: "Top",
			controller:this
        });
        
        
        this.addView({
            key: "squareEast",
            type: "mediumRectangle",
            renderTo: J.fc.getZone("adMediumRectangle"),
            position: "Middle",
			controller:this
        });
		
	
        
		
        /*
         this.views.add("verticalBanner", new J.View.AdView({
         type: "verticalBanner",
         zone: "adSocialMenu"
         }));
         */
        // Init each view
		
       setTimeout("J.fc.getController('ad',true).view.get('headerMegaBanner').init();",3000);
       
	  setTimeout("J.fc.getController('ad',true).view.get('squareEast').init();",5000);
		
		Ext.TaskMgr.start(this.task);
		
		
        
    },
   reloadAdsense : function(id){
   	
	
   },
    /**
     * Forces the refreshing of registered views
     */
	busy:false,
    refreshContent: function() {
		
			cat = Ext.get("pub-categories");
			if(cat){
				cat.update(this.getCatAds());
			}
		
			
	
    }, 
	refresh: function() {
		if (this.busy == false) {
			this.busy =true;
			//console.log('square Ad');
			
			var time =1000;
			 setTimeout("J.fc.getController('ad',true).view.get('headerMegaBanner').refresh();",time);
		  //	console.log('Banner Ad');
			time = time+2000;
	       //console.log('Change Ad');
		setTimeout("J.fc.getController('ad',true).view.get('squareEast').refresh();",time);
			
		/*   
			this.comment =   document.getElementById('adsense-comment');
			this.vertical =   document.getElementById('adsense-vertical');
			this.content =   document.getElementById('adsense-content');
			
			
			if(this.comment){
				time = time+1000;
				setTimeout("J.fc.getController('ad',true).reloadAdsense('comment')",time);
			}
			
			if(this.vertical){
				time = time+1000;
				setTimeout("J.fc.getController('ad',true).reloadAdsense('vertical')",time);
			}
			
			if(this.content){
				time = time+1000;
				setTimeout("J.fc.getController('ad',true).reloadAdsense('content')",time);
			}
	*/		
			time = time+1000;
			setTimeout("J.fc.getController('ad',true).setChange();",time);
	   
		//	
		}	
		
    },
	setChange : function(){
		
		
		this.busy =false;
		this.change = true;
		
	},
	getUpdateUrlList :function(){
		
			this.urlList = new Array();
		
		
		if (!J.fc.PubProfile.age) {
			J.fc.PubProfile.age = Math.floor(Math.random() * 50);
				if (J.fc.PubProfile.age < 16) {
					J.fc.PubProfile.age = 20;
				}
		}
		
		if (!J.fc.PubProfile.sex) {
			J.fc.PubProfile.sex = "m";
		}
		
		if (J.fc.PubProfile.social) {
			this.urlList.push("www.facebook.com");
		}
		
		
		if (J.fc.PubProfile.age >= 20) {
			this.urlList.push("www.nouvelles-frontieres.fr");
			this.urlList.push("www.assurland.com");
			this.urlList.push("www.pap.fr");
		}
				
		if (J.fc.PubProfile.age < 30) {
			this.urlList.push("www.megasonnerie.com");
		}
		
		
		if (J.fc.PubProfile.sex == 'f') {
			this.urlList.push("www.elle.fr");
		}
		
		
		this.urlList.push("divertissement.aol.fr");
		this.urlList.push("www.cdiscount.com");
		this.urlList.push("www.pixmania.com");
		this.urlList.push("www.ebay.fr");
		this.urlList.push("www.musique.fr");
		this.urlList.push("www.concert.fr");
		this.urlList.push("www.toutgagner.com");
		
		
		return this.urlList;
	},
    /**
     * Create and register a new view.
     * @param {Object} options
     * @return the view
     */
    addView: function(options) {
    
        var  view = new J.View.Ad(options);
        
        this.view.add(options.key, view);
        
        return view;
    },
    
    /**
     * Remove the view whose key is specified. Delete the iframe, etc.
     * @param {String} key
     */
    removeView: function(key) {
        var view = this.view.get(key);
        if (view) {
            view.destroy();
        }
        
    },
    
    /**
     * Hide view => new ads won't load in this view.
     * @param {String} key
     */
    hideView: function(key) {
        var view = this.view.get(key);
        if (view) {
            view.hidden = true;
        }
    },
    
    /**
     * Show view ==> new ads will load in this view
     * @param {String} key
     */
    showView: function(key) {
        var view = this.view.get(key);
        if (view) {
            view.hidden = false;
        }
    }
});
jwPlayer = null;

J.Controller.Player = Ext.extend(J.Controller.Base, {
    maxTime: null,
    preload: false,
	currentIndex:-1,
	sourceId:null,
	sourceType:null,
	logginPaused :false,
	randomIndex:0,
	mode:'ON_DEMAND',
    init: function(){
        this.model = new J.Model.Player({
            controller: this
        });
        /* Create view */
        this.view = new J.View.Player({
            zone: "player",
            controller: this
        });
        
        jwPlayer = this;
        
        this.view.render();
		
    },
    /*******************************************************************************************************************
     * ENGINE INTERFACES
     ******************************************************************************************************************/
    jwAddTracks: function(tracks, options,show){
    
		
			if (this.mode != "ON_DEMAND") {
				this.model.store.removeAll();
				this.model.radioStore.removeAll();
			}
			
			this.type = null;
			
			this.mode = "ON_DEMAND";
			
			this.view.refreshMode();
			
			
			this.model.addTracks(tracks, options);
			
			
			if (show == undefined) {
				if (tracks.length > 1) {
					J.InfoBox.msg("Les pistes ont été ajoutée au player");
				}
				else {
					J.InfoBox.msg(tracks[0].songName + " - " + tracks[0].artistName + " a été ajoutée au player", 1);
				}
				
			}
		
    },
    jwPlayTrackAtIndex: function(track, index){
		
			track.mode = this.mode;
			this.view.selectTrack(index);
			this.currentIndex = index;
			this.engine.jwPlayTrack(track, this.mode);
			J.fc.controllers.get("ad").refresh();
		
    },
    jwSetPosition: function(time){
        this.engine.jwSetPosition(time);
    },
    jwSetVolume: function(volume){
        this.view.setVolume(volume);
        this.engine.jwSetVolume(volume);
    },
    jwAddPlaylist: function(playlistId, options){
		
        J.track('play', J.fc.name);
		this.sourceType ='playlist';
		this.sourceId = playlistId;
        this.model.launchPlaylist(playlistId, options);
    },
    jwAddAlbum: function(albumId, options){
    
        J.track('play', J.fc.name);
        this.model.launchAlbum(albumId, options);
    },
	jwAddTrack: function(trackId, options){
    
        J.track('play', J.fc.name);
		
		
        this.model.launchTrack(trackId, options);
    },
    jwPlayRadio: function(radioId, radioName, type){
    
        this.view.radioIcon.update("RADIO");
        if (type == undefined) {
            type = 'radio';
        }
        J.track('play', J.fc.name);
        J.track('launch', 'radio', type);
        
        this.type = type;
        this.id = radioId;
        this.view.radioName.update(radioName);
        this.refreshAction();
		
		this.model.launchRadio({
		                radioId: radioId,
		                type: type
		            }, "RADIO");
		return 
    },
    jwLaunchSimiliRadio: function(radioId, radioName, type){
    
        Ext.MessageBox.wait(tr('popup_msg_wait'));
        this.view.radioIcon.update("SMART<br/>RADIO");
        J.track('play', J.fc.name);
        J.track('launch', 'smart', type);
		
        if (type == undefined) {
            type = 'radio';
        }
        if (type == 'radio') {
            if (radioId > 0) {
                this.type = type;
                this.id = radioId;
                this.view.radioName.update(radioName);
                this.refreshAction();
				return this.model.launchRadio({
		                radioId: radioId,
		                type: type
		            }, "INTERACTIVE_RADIO");
            }
            else 
                if (this.currentTrack.artistId) {
                    this.type = type;
                    this.id = this.currentTrack.artistId;
                    this.view.radioName.update(this.currentTrack.artistName);
                    this.refreshAction();
					return this.model.launchRadio({
		                radioId: this.currentTrack.artistId,
		                type: type
		            }, "INTERACTIVE_RADIO");
                }
        }
        else {
            this.type = type;
            this.id = radioId;
            this.view.radioName.update(radioName);
            this.refreshAction();
            return this.model.launchRadio({
                radioId: radioId,
                type: type
            }, "INTERACTIVE_RADIO");
        }
		
    },
    refreshAction: function(){
        this.view.refreshAction();
    },
    jwNext: function(){
    
        
        if (this.mode == "ON_DEMAND") {
            this.playNextSong();
        }
        else 
            if (this.mode == "INTERACTIVE_RADIO") {
                this.playNextSong();
            }
    },
    jwPrevious: function(){
       if (this.mode == "ON_DEMAND") {
            this.playPreviousSong();
       }
    },
    jwPause: function(){
		
        return this.engine.jwPause();
    },
	jwPlayAd: function(){
		
        return this.engine.jwPlayAd();
    },
    jwResume: function(){
       
	 
	   	if (this.preload) {
	   		this.preload = false;
	   		return this.model.playIndex(0);
	   		
	   	}
	   	else {
	   		return this.engine.jwResume();
	   	}
	   	
        
    },
    jwGetTrack: function(){
        return this.engine.jwGetTrack();
    },
    jwGetMode: function(){
        return this.mode;
    },
    jwGetPosition: function(){
        return this.engine.jwGetPosition();
    },
    jwGetLoadProgress: function(){
        return this.engine.jwGetLoadProgress();
    },
    jwToggleShuffleMode: function(toggle){
		this.randomIndex=0;
		
        return this.model.setShuffle(toggle);
    },
	
    jwToggleRestrictedMode: function(toggle){
        return this.model.setRestricted(toggle);
    }, jwToggleRepeatMode: function(toggle){
        return this.model.setRepeat(toggle);
    },
    jwRemoveTracks: function(firstPosition, nbTracks){
		
		var index = this.currentIndex - firstPosition;
		if(index >=0 && index<=nbTracks){
			this.currentIndex = parseInt(firstPosition+nbTracks-1);
			this.jwNext();
		}
		
        this.model.removeTracks(firstPosition, nbTracks);
    },
    jwClearQueue: function(){
        return this.model.clearQueue();
    },
    
    
    /*******************************************************************************************************************
     * ENGINE HANDLERS
     ******************************************************************************************************************/
    engineReadyHandler: function(){
		this.engine = document.getElementById("jwPlayer");
        var vol = this.model.getVolume();
        this.view.setVolume.defer(100, this.view, [vol]);
		
		J.fc.playerReady = true;
		
		if (!J.first && !J.fc.played) {
				J.fc.played =true;
                J.fc.play();
						
         }

    },
    engineQueueAddHandler: function(tracks, insertIndex, currentIndex){
    
        this.model.addTracks(tracks, insertIndex);
    },
    engineClearQueueHandler: function(){
        this.model.clearQueue();
        this.view.setPaused(false);
        return true;
    },
    engineEndQueueHandler: function(){
        this.view.setPlayMode(false);
    },
    engineRemoveTracksHandler: function(firstIndex, nbTracksRemoved){
        this.view.downloadCurrentTrack.disable();
        this.model.removeTracks(firstIndex, nbTracksRemoved);
    },
    engineQueueMoveHandler: function(tracks, position, before){
    
    },
    engineLoadingTrackHandler: function(track){
        this.view.refreshMode();
        this.currentTrack = track;
        this.view.loadTrack(track);
    },
    preLoadTrackHandler: function(track, currentIndex){
       this.view.refreshMode();
       this.currentTrack = track;
        this.preload = true;
        this.view.loadTrack(track, currentIndex, true);
    },
    enginePlayTrackHandler: function(track){
        
		  
		  	if (!track.starzikTrackUrl &&!track.itunesTrackUrl) {
		  		this.view.downloadCurrentTrack.disable();
		  	}
		  	else {
		  		this.view.downloadCurrentTrack.enable();
		  	}
		  	
		  	this.view.refreshMode();
		  	this.currentTrack = track;
		  	this.model.reqSimilarTracks(track);
		  
    },
    enginePauseTrackHandler: function(){
    
        this.view.setPaused(true);
    },
    engineResumeTrackHandler: function(){
    /*inscription obligatoire
     * 
     * 
     * 
     * if (!J.me.isLoggedIn()) {
	   	this.jwPause();
	   	J.me.controller.requireLogin();
	   	this.logginPaused=true;
	   }else {
	   	this.view.setPaused(false);
	   }
     */
    
	   	this.view.setPaused(false);
	
	
    },
    engineProgressHandler: function(currentTimeInt, maxTimeInt, currentTimeStr, maxTimeStr, loaded){
        this.maxTime = maxTimeInt;
        this.view.setProgress(currentTimeInt, maxTimeInt, currentTimeStr, maxTimeStr, loaded);
        
    },
    engineCompletePlayHandler: function(){
    	this.view.setPaused(false);
        this.playNextSong();
    },
    log: function(){
    
    },
    /*******************************************************************************************************************
     * MY HANDLERS
     ******************************************************************************************************************/
    progressClickHandler: function(sec){
        this.jwSetPosition(sec);
    },
    
    mute: function(){
        var vol = this.model.getVolume();
        
        if (vol == 0) {
            vol = this.model.DEFAULTVOLUME;
        }
        else {
            vol = 0;
        }
        this.jwSetVolume(vol);
    },
    down: function(){
    
    },
    isFan: function(){
        if (this.type) {
            if (this.type == 'radio') {
                return J.fc.getController('station', true).isFan(this.id);
            }
            return J.fc.getController(this.type, true).isFan(this.id);
        }
        
        return false;
    },
    unsubscribe: function(){
        if (this.type) {
            if (this.type == 'radio') {
                return J.fc.getController('station', true).unsubscribe(this.id);
            }
            return J.fc.getController(this.type, true).unsubscribe(this.id);
        }
        
        return false;
    },
    subscribe: function(){
        if (this.type) {
            if (this.type == 'radio') {
                return J.fc.getController('station', true).subscribe(this.id);
            }
            return J.fc.getController(this.type, true).subscribe(this.id);
        }
        
        return false;
    },
    share: function(){
    
        if (this.currentTrack) {
            if (this.currentTrack.trackId) {
                J.Seo.init(this.currentTrack, 'track').share();
            }
        }
        
    },
    permalink: function(){
    
        if (this.currentTrack) {
            if (this.currentTrack.trackId) {
            
                J.Seo.init(this.currentTrack, 'track');
                
                
                var popup = new J.Popup({
                    title: tr('link'),
                    trackController: 'permalink',
                    trackAction: "player",
                    big: true,
                    fields: [{
                        type: 'text',
                        fieldLabel: '',
                        style: 'width:500px',
                        width: 600,
                        hideLabel: true,
                        value: J.Seo.url
                    }],
                    buttons: [{
                        text: tr('popup_button_close'),
                        handler: function(){
                            popup.win.close();
                        }
                    }]
                });
                
                
            }
        }
    },
    download: function(){
        if (this.currentTrack) {
            if (this.currentTrack.trackId) {
                if (this.currentTrack.starzikTrackUrl) {
                    J.track('starzik', 'download','track');
                    window.open( this.currentTrack.starzikTrackUrl, "Jiwa Download - starzik", "");   
				}else if (this.currentTrack.itunesTrackUrl) {
                    J.track('itunes', 'download','track');
                    window.open('http://clk.tradedoubler.com/click?p=23753&partnerId=2003&a=1570290&g=0&td_partnerId=2003&url=' + this.currentTrack.itunesTrackUrl, "Jiwa Download - Itunes", "");   
				}
                else {
                    J.InfoBox.msg("Ce morceau n'est pas encore disponible en téléchargement");
                }
            }
            else {
                J.InfoBox.msg("Aucun morceau n'est séléctionné");
            }
        }
        else {
            J.InfoBox.msg("Aucun morceau dans la playlist");
        }
    },
    
    
    playPreviousSong: function(){
       
	    if (this.mode == "ON_DEMAND") {
		
			this.currentIndex--;
			
			if (this.currentIndex < 0) {
				this.currentIndex = 0;
			}
			
			if(this.model.shuffle){
				if (this.randomIndex< 0) {
					this.randomIndex = 0;
				}
				
				var record = this.model.radioStore.getAt(this.randomIndex);
				var index = this.model.store.find('songId',record.data.songId);
				
		        if (record) {
		            this.jwPlayTrackAtIndex(record.data,index);
		        }
				
				
				
				
				return this.randomIndex--;
				
			}
			
		}
		
		
        
        var track = this.model.getTrackAtIndex(this.currentIndex, this.mode);
        if (track) {
            this.jwPlayTrackAtIndex(track, this.currentIndex);
        }
        
        
    },
    playNextSong: function(){
    
		if (this.mode == "ON_DEMAND") {
		this.currentIndex++;	
			if (this.model.store.getCount() <= this.currentIndex) {
				if (this.model.getRepeat()) {
					this.currentIndex = 0;
				}
			}
			
			if(this.model.shuffle){
				if (this.model.radioStore.getCount() <= this.randomIndex) {
					this.randomIndex = 0;
				}
				
				var record = this.model.radioStore.getAt(this.randomIndex);
				var index = this.model.store.find('songId',record.data.songId);
				
		        if (record) {
		            this.jwPlayTrackAtIndex(record.data,index);
		        }
				
				return this.randomIndex++;
				
			}
			
		}

        var track = this.model.getTrackAtIndex(this.currentIndex, this.mode);
        if (track) {
           return this.jwPlayTrackAtIndex(track, this.currentIndex);
        }
    }
    /**
     *
     */
});

J.Controller.MainMenu = Ext.extend( J.Controller.Base, {

	init: function() {
		/* Create view */
		this.view = new J.View.MainMenu({
			zone: "mainMenu",
			controller:this
		});
		
		this.view.render();
	},
	setActiveButton: function(buttonId) {
		if (this.view) {
			this.view.setActiveButton(buttonId);
		}
		
	},
 	 hideConnect :function(){
		if(this.view){
		
		
		var menu = Ext.get("zone-helpMenu");
			if(menu){
				menu.update('<a onClick="J.fc.gotoUrl(\'user\','+J.me.userId+')" >'+tr('leftMenu_myProfile')+
					'</a> <span class="puce"></span><a onClick="J.fc.getController(\'account\',true).logout();" >'+
					tr('mainMenu-disconnect')+'</a>');
			}
	
		}
	},
	adminClickHandler: function(buttonId) {
		switch (buttonId) {
			case "adminNews":
				J.fc.gotoUrl("admin", "news", "incoming");
				break;
			case "adminBoxes":
				J.fc.gotoUrl("admin", "boxes");
				break;
			case "adminTradTool":
				J.fc.gotoUrl("admin", "trad");
				break;
			case "monitoring":
			var win = new Ext.Window( {
					title: 'monitoring',
					html : '<div height="220" width="330" id="wsMonitor"><embed height="220" width="330" quality="best" bgcolor="#000" name="WSMonitor" id="WSMonitor" style="" src="/res/swf/WSMonitor.swf" type="application/x-shockwave-flash"/></div>'
					,closable:true,
					height:220,
					width:330
				});
				win.show();
				break;
			case "normalscreen":
				J.fc.render();
				break;
			case "previewEdito":
				J.fc.getController("home",true).focus.editoPreview();
				J.fc.gotoUrl("home");
				break;
				
			case "generateEdito":
				J.fc.getController("home",true).focus.editoGeneration();
				J.fc.gotoUrl("home");
				
			default:
				J.fc.gotoUrl(buttonId);
		}
	}
	
});
J.Controller.Search = Ext.extend(J.Controller.Base, {
	domain : null,
	baseUrl:'search',
    init: function() {

        // Create search view
        this.viewBar = new J.View.Search({
            controller: this
        });
		
        this.viewBar.render();
    },
	up:function(){
		
		 this.view = new J.View.Results({
                controller: this
          });
		
		this.view.render();
		this.rendered=true;
	},
    search: function(domain, params) {
        // TODO: check if this is the same domain. In this case, do not destroy.
        if (this.store) {
            this.store.destroy();
        }
	
		
        this.domain = domain;
		this.baseParams = params;
		
		this.baseParams.noRestricted = jwPlayer.model.restricted;
		
        
        if (domain == "track") {
            this.store = new Ext.data.Store({
						
			remoteSort:true,
				reader: new Ext.data.JsonReader({
					root: "page",
					id: 'trackId',
					totalProperty: "total"
				}, J.Record.Track),
				baseParams : params,
				url: 'track/search'
			});
			
        } else if (domain == "user") {
			
			this.store = new Ext.data.Store({		
				remoteSort:true,
		        reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
					id: "userId"
		        }, J.Record.User),
				baseParams : params,
				url: 'user/search'
		    });

        } else if (domain == "playlist") {

		    this.store = new Ext.data.Store({		
			remoteSort:true,
		        reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
		            id: "playlistId"
		        }, J.Record.Playlist),
				baseParams : params,
				url: 'playlist/search'
		    });
        
        }else if (domain == "album") {

		    this.store = new Ext.data.Store({		
			remoteSort:true,
		        reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
		            id: "albumId"
		        }, J.Record.Album),
				baseParams : params,
				url: 'album/search'
		    });
        
        }else if (domain == "artist") {

		    this.store = new Ext.data.Store({		
			remoteSort:true,
		        reader: new Ext.data.JsonReader({
					root: "page",
					totalProperty: "total",
		            id: "artistId"
		        }, J.Record.Artist),
				baseParams : params,
				url: 'artist/search'
		    });
        
        }
		
		this.view.renderResults(domain,this.store);
		
			
    }
});

J.Controller.Footer = Ext.extend( J.Controller.Base, {

	/**
	 * Load the data from T and render the footer.
	 */
    init: function() {
        this.view = new J.View.Footer({
            controller: this
        });
        
        this.view.render(arrTr("footer"));
    }
    
});

J.Controller.PlaylistAdder = Ext.extend( J.Controller.Base, {
	init: function() {
		this.model = new J.Model.PlaylistAdder({controller:this});
		this.view = new J.View.PlaylistAdder({controller:this});
	},
	show: function(tracksRecords) {
		if (J.me.isLoggedIn()) {
			this.model.setTracksRecords(tracksRecords);
			this.view.render();
		}
	},
	create:function(tracksRecords){
		
		
		if (tracksRecords != undefined) {
			this.model.setTracksRecords(tracksRecords);
		}
		
		J.fc.getController("playlist",true).edit({},tr('playlist_popup_create_title'),{url: '/playlist/create'},true);
	},
	afterPlaylistCreate :function(data){
		if (this.model.tracksRecords.records.length > 0) {
			this.model.reqAddToPlaylists([data.edited.playlist.playlistId]);	
		}
	},
	addAlltracksOfGrid :function(grid){
		if (J.me.isLoggedIn()) {
			var tracks = [];
			grid.store.data.each(function(item, record, a){
				tracks.push(item);
			});
			this.show({
				records: tracks
			});
		}
	},
	removeTracks : function(tracksRecords,playlistId,store,start,limit){
		if (J.fc.controller.baseUrl == "playlist" && J.fc.controller.mine()) {
			this.model.reqRemoveFromPlaylist(tracksRecords, playlistId, store,start,limit);
		}
	},
	moveTracks : function(tracksRecords,playlistId,store,position,start,limit){
		if (J.fc.controller.baseUrl == "playlist" && J.fc.controller.mine()) {
			this.model.reqMoveFromPlaylist(tracksRecords, playlistId, store,position,start,limit);
		}
	},
	down:function(){
		
	}
});


J.Controller.Home = Ext.extend(J.Controller.Base, {
	baseUrl:'home',
	init: function() {
		this.model = new J.Model.Home({
			controller: this
		});
		this.focus = new J.Model.Focus();
	},
	show: function() {
		J.fc.preview=true;
		this.view = new J.View.Home({
			controller: this
		});
		this.view.init();
		this.model.reqData();
		
		// Focus view
		this.focusView = new J.View.Focus({
			controller: this
		});
		this.focusView.render(this.focus);
	},
	
	updateFocus: function(){
		this.focusView.destroy();
		this.focusView = new J.View.Focus({
			controller: this
		});
		this.focusView.render(this.focus);
	},
	down: function() {
		J.Controller.Home.superclass.constructor.call(this);
		this.focusView.destroy();		
		this.view.destroy();
	}
});

J.Controller.Comment = Ext.extend( J.Controller.Base, {
	constructor: function(p) {
		this.model = new J.Model.Comment({
				controller: this,
				store :p.store
			});
	
			this.view = new J.View.Comment({
				controller: this,
				anchor:'100%',
				store :p.store,
				renderTo: p.renderTo
			});
		p.store.load();
	},
	onProblem: function(commentId) {
		return J.Problem.show({objCls: 'comment', objId: commentId});
	},
	onPost: function(p) {
		
		if (J.me.isLoggedIn) {
			this.model.addComment(p);
		}
	},
	deleteComment: function(commentId){
		if(J.fc.controller.mine()){
			this.model.deleteComment(commentId);
		}
	}
	
});
J.Controller.Mail = Ext.extend( J.Controller.Base, {
	baseUrl:'mail',
	constructor: function(p) {

		if (p) {
			this.model = new J.Model.Mail({
				controller: this,
				store: p.store
			});
			/* Create view */
			this.view = new J.View.Mail({
				controller: this,
				anchor: '100%',
				store: p.store,
				renderTo: p.renderTo
			});
			
			p.store.load();
			
			J.me.reqCheck();
		}else{
			this.model = new J.Model.Mail({
				controller: this
			});
		}
	},
	onPost: function(p) {
		if (J.me.isLoggedIn) {
			this.model.addMail(p);
		}
	}
});

J.Controller.Text = Ext.extend( J.Controller.Base, {
	baseUrl:'text',
	up: function(){
		this.model = new J.Model.Text({controller : this });
		this.view = new J.View.Text({controller : this });
		
		this.view.render();
	},
	show: function(id) {
	
		this.id = id;
		
		var keys = {
				'promo' : {title: 'PROMO'},
				'faq' : {title: 'FAQ'},
				'jiwa' : {title: 'A propos de JIWA'},
				'jobs' : {title: 'Travailler à JIWA'},
				'how' : {title: 'Comment ça marche, JIWA'},
				'contact' : {title: 'Contacter JIWA'},
				'edito' : {title: 'Quoi de neuf ?'},
				'illicit' : {title: 'Contenu illicite?'},
				'tou' : {title: 'TOU'},
				'legal' : {title: 'legal'},
				'press' : {title: 'press'},
				'dataPrivacy' : {title: 'dataPrivacy'}
		};
			var infos = keys[id];
			if(infos) {
				this.model.reqText(id,infos.title);
			
			}
	
		this.view.rendered =true;

	}
});
/**
 * @author steeve
 */
J.Controller.Openfire = Ext.extend(J.Controller.Base, {

    /**************************************
     * 				Controler
     **************************************/
    init: function(){
        
		/*
		this.view = new Object();
		//Initialisation de l'objets de debug
        this.oDbg = new JSJaCConsoleLogger(3,'jiwa');
        //oDbg = function() {};
        //oDbg.log = function() {};
		
		*/
    },
    
    login: function(oParams){
		
		//Appel de l'initialisation annexe
		this.init();
		
    	// Définition des arguments pour le construteur
	    oArgs = new Object();
	    oArgs.httpbase = 'http://tamtam.jiwa/http-bind/';
	    oArgs.timerval = 2000;
		
		//Récupération des informations de debuguage
		if (typeof(this.oDbg) != 'undefined') {
			oArgs.oDbg = this.oDbg;
		}
		
		//Création de l'objet de connexion
		J.fc.con = new JSJaCHttpBindingConnection(oArgs);
		this.setupCon();
		 
		oArgs = new Object();
		oArgs.domain = oParams.domain;
		oArgs.username = oParams.username;
		oArgs.resource = 'Jiwa Chat';
		oArgs.pass = oParams.pass;
		oArgs.register = 0;
		oArgs.authtype = 'nonsasl';
		
		J.fc.con.connect(oArgs);
		 
    },
	
	setupCon: function() {
		
		

	    J.fc.con.registerHandler('message',this.handleMessage);
	    J.fc.con.registerHandler('presence',this.handlePresence);
	   	J.fc.con.registerHandler('iq',this.handleIQ);
	    J.fc.con.registerHandler('onconnect',this.handleConnected);
	    J.fc.con.registerHandler('onerror',this.handleError);
	    J.fc.con.registerHandler('status_changed',this.handleStatusChanged);
	    J.fc.con.registerHandler('ondisconnect',this.handleDisconnected);
	
	    J.fc.con.registerIQGet('query', NS_VERSION, this.handleIqVersion);
	    J.fc.con.registerIQGet('query', NS_TIME, this.handleIqTime);
	},
    
    quit: function(){
    	  var p = new JSJaCPresence();
		  p.setType("unavailable");
		  J.fc.con.send(p);
		  J.fc.con.disconnect();
    },
    
    sendMsg: function(){
    
    },
    /**************************************
     * 				Handler
     **************************************/
    handleMessage: function(aJSJaCPacket){
		/*
		 * Action à effectuer lors de la reception d'un message
		 * Origine = aJSJaCPacket.getFromJID()
		 * Message = aJSJaCPacket.getBody().htmlEnc()
		 */
		var form = new Ext.form.FormPanel({
	        baseCls: 'x-plain',
	        labelWidth: 55,
	        defaultType: 'textfield',
	
	        items: [{
	            fieldLabel: 'Send To',
	            name: 'to',
	            anchor:'100%'  // anchor width by percentage
	        },{
	            xtype: 'textarea',
	            hideLabel: true,
	            name: 'msg',
	            anchor: '100% -53',  // anchor width by percentage and height by raw adjustment
	            value:aJSJaCPacket.getBody().htmlEnc()
	        }]
	    });
		var window = new Ext.Window({
	        title: 'Resize Me',
	        width: 500,
	        height:300,
	        minWidth: 300,
	        minHeight: 200,
	        layout: 'fit',
	        plain:true,
	        bodyStyle:'padding:5px;',
	        buttonAlign:'center',
	        items: form,
	        buttons: [{
	            text: 'Send'
	        }]
	    });
		
		window.show();		
    
    },
    
    handlePresence: function(aJSJaCPacket){
		/*
		 * Action à effectuer lors de la reception d'une indication de présence
		 */
    
    },
    
    handleIQ: function(aIQ){
		/*
		 * Acceder au information serveur
		 * Sortie XML = aIQ.xml().htmlEnc()
		 * Erreur possible = aIQ.errorReply(ERR_FEATURE_NOT_IMPLEMENTED)
		 */
    	
    },
    
    handleConnected: function(){
		/*
		 * Action lorque le client se connecte et que son identification est un succès
		 */
		J.fc.con.send(new JSJaCPresence());
    },
    
    handleError: function(e){
		/*
		 * Code = e.getAttribute('code')
		 * Type = e.getAttribute('type')
		 * Condition = e.firstChild.nodeName).htmlEnc()
		 */
    	if (J.fc.con.connected()) {
			J.fc.con.disconnect();
		}
    },
    
    handleStatusChanged: function(status){
    	/*
    	 * Changement de status, action à effectué
    	 */
    },
    
    handleDisconnected: function(){
    	/*
    	 * Gestion des actions lorque l'on se deconnect (windows)
    	 */
		alert("Deconnexion du chat");
    },
    
    handleIqVersion: function(){
        J.fc.con.send(
			iq.reply([
				iq.buildNode('name', 'Jiwa Chat'), 
				iq.buildNode('version', JSJaC.Version), 
				iq.buildNode('os', navigator.userAgent)
			])
		);
        return true;
    },
    
    handleIqTime: function(){
    	var now = new Date();
  		J.fc.con.send(
			iq.reply([
				iq.buildNode('display', now.toLocaleString()),
                iq.buildNode('utc', now.jabberDate()),
                iq.buildNode('tz', now.toLocaleString().substring(now.toLocaleString().lastIndexOf(' ')+1))
            ])
		);
  		return true;
    },
    /**************************************
     * 				Error
     **************************************/
    onerror: function(){
    
    },
    
    onunload: function(){
    
    },
	
	/**************************************
     * 				Window
     **************************************/
    openWindow:function(user){
		alert(user.userName+"\n"+user.userId);
		
	}
});

J.Controller.Artist = Ext.extend(J.Controller.Card, {
    baseUrl: "artist",
    defaultCategory: "tracks",
    defaultInc: "biography",
    up: function(){
        this.model = new J.Model.Artist({
            controller: this
        });
        this.view = new J.View.Artist({
            controller: this
        });
    },
	isHidden:function(){
		if(this.model.getField('hidden') == true){
			return true;
		}else{
			return false;
		}
	},
	hiddenElement: function(){
		this.model.setDisplay(1);
	},
	displayElement:function(){
		this.model.setDisplay(0);
	},
	restrictElement:function(){
		this.model.setRestrict(1);
	},
	allowElement:function(){
		this.model.setRestrict(0);
	},
    updateTextCardDescription: function(){
        return {
            similar: tr('suggestions_similiRadio'),
            play: tr('contextMenu_artist_similaRadio'),
            tools: tr('button_card_altmenu_edit_artist')
        };
    },
    similar: function(id, name){
        if (id == undefined) { id = this.id;}
        if (name == undefined) {name = this.model.getField('artistName');}
        J.fc.getController("player", true).jwLaunchSimiliRadio(id, name, 'radio');
    },
    play: function(id, name){
        if (id == undefined) {
            id = this.id;
        }
        
        if (name == undefined) {
            name = this.model.getField('artistName');
        }
        J.fc.getController("player", true).jwLaunchSimiliRadio(id, name, 'artist');
        
    },
    isExportable: function(){
    
        return true;
    },
    isFan: function(id){
    
        if (id == undefined) {
            id = this.id;
        }
        if (J.me.loggedIn) {
        
            if (J.me.ArtistsStore) {
                return J.me.ArtistsStore.getById(id);
            }
        }
        
        return false;
    },
	setPicture :function(id){
		if(id == undefined){
			id  = this.id;
		}
		
		
		return new J.Popup({
				title: tr('playlist_popup_picture_title'),
				msg: tr('playlist_popup_picture_msg'),
				submit: {
					url: '/artist/setpicture', 
					params: {
						artistId: this.id
					}
				},
				trackController: 'artist',
				trackAction: 'setPicture',
				big:true,
				success: this.refresh,
				scope: this,
				fileUpload: true,
				fields:
				[
					{
						type: 'field',
						inputType: 'file',
						fieldLabel: tr('playlist_popup_picture_label_picture'),
						name: 'picture'
					}
				]
			});
		
		
	},
	editGenre: function(id){
		if (id == undefined) {
            id = this.id;
        }
		data = this.model.record.data;
		return new J.Popup({
            title: tr('edit-style'),
            msg: tr('edit-style'),
            submit: {
                url: '/artist/setstyle',
                params: {
                    artistId: this.id
                }
            },
            trackController: 'artist',
            trackAction: 'edit-style',
            success: this.afterSetStyle,
            scope: this,
            fields: [{
				type: 'select',
				data: arrTr('themes'),
				name: 'style',
				fieldLabel: tr('select_themes_main'),
				value: data.style,
				validationEvent: 'blur'
			},{
				type: 'select',
				data: arrTr('themes'),
				name: 'styleSecondary',
				fieldLabel: tr('select_themes_secondary'),
				value: data.styleSecondary,
				validationEvent: 'blur'
			}]
        });
	},
    editTag: function(){
		if (this.id) {
			new J.Popup({
				title: tr('playlist_infos_buton_tag'),
				msg: tr('playlist_popup_tag_msg'),
				submit: {
					url: '/artist/tagedit',
					params: {
						artistId: this.id
					}
				},
				success: this.afterPlaylistEdit,
				trackController: 'artist',
				trackAction: 'editTag',
				scope: this,
				requireLogin: true,
				armEnter: false,
				fields: [{
					type: 'textArea',
					fieldLabel: tr('playlist_infos_label_tags'),
					name: 'tags',
					style: 'height: 150px',
					maxLength: '120',
					allowBlank: true
					//value: this.model.getField('tags')
				}]
			});
		}
    },
    afterSetStyle: function(data){
        if (data) {
            this.model.update(data.edited);
        }
    }
});

J.Controller.Album = Ext.extend(J.Controller.Card, {
    baseUrl: "album",
    defaultCategory: "tracks",
    defaultInc: "artists",
    up: function(){
    
        this.model = new J.Model.Album({
            controller: this
        });
        
        this.view = new J.View.Album({
            controller: this
        });
        
    },
	buy : function(id,name){
        if (id == undefined) {
            id = this.id;
        }
		
		if (name == undefined) {
            name = this.model.getField('albumName');
        }
		
		 if (!J.me.isLoggedIn()) {
                    J.me.controller.requireLogin();
         }else{
			
			J.track('hipay', 'album');
			
			var data = {};
			data.mode='MODE_A';
		    data.website_id='1280' ;
		    data.user_account_id='62762';
		  	data.currency='EUR'; 
			data.category_id='237';
		   	data.label=name;
		   	data.age_group='ALL';
		   	data.url_acquital='http://www.jiwa.fr/album/pay?userId='+J.me.userId+'&albumId='+id;
		  	data.url_ok=J.Seo.host+'/album/download?albumId='+id;
		  	data.url_ko=J.Seo.host;
		  	data.url_install=J.Seo.host; 
			data.items = {};
			
			var product ={};
			
			product.name = name;
	
   product.amount='8.35';
   product.category_id='237';
   product.quantity='1';
   product.infos='';
   product.reference = 'REF1';
   product.taxe_amount = '1.64';
   product.taxe_label = 'TVA';
   
  
 if (J.me.userId == 18845) {

   	data.website_id = '226';
   	data.user_account_id = '22632';
   	
   	window.open('https://test.payment.hipay.com/index/form/?' + Ext.urlEncode(data) +
   	'&' +
   	encodeURIComponent('items[1][name]') +
   	'=' +
   	encodeURIComponent(product.name) +
   	'&' +
   	encodeURIComponent('items[1][amount]') +
   	'=' +
   	encodeURIComponent(product.amount) +
   	'&' +
   	encodeURIComponent('items[1][quantity]') +
   	'=' +
   	encodeURIComponent(product.quantity) +
   	'&' +
   	encodeURIComponent('items[1][infos]') +
   	'=' +
   	encodeURIComponent(product.infos) +
   	'&' +
   	encodeURIComponent('items[1][reference]') +
   	'=' +
   	encodeURIComponent(product.reference) +
   	'&' +
   	encodeURIComponent('items[1][category_id]') +
   	'=' +
   	encodeURIComponent(product.category_id)+
	'&' +
   	encodeURIComponent('items[1][taxes][1][label]') +
   	'=' +
   	encodeURIComponent(product.taxe_label)+
	'&' +
   	encodeURIComponent('items[1][taxes][1][amount]') +
   	'=' +
   	encodeURIComponent(product.taxe_amount), "Jiwa Buy - Hipay", "");


}else{
   	window.open('https://payment.hipay.com/index/form/?' + Ext.urlEncode(data) +
   	'&' +
   	encodeURIComponent('items[1][name]') +
   	'=' +
   	encodeURIComponent(product.name) +
   	'&' +
   	encodeURIComponent('items[1][amount]') +
   	'=' +
   	encodeURIComponent(product.amount) +
   	'&' +
   	encodeURIComponent('items[1][quantity]') +
   	'=' +
   	encodeURIComponent(product.quantity) +
   	'&' +
   	encodeURIComponent('items[1][infos]') +
   	'=' +
   	encodeURIComponent(product.infos) +
   	'&' +
   	encodeURIComponent('items[1][reference]') +
   	'=' +
   	encodeURIComponent(product.reference) +
   	'&' +
   	encodeURIComponent('items[1][category_id]') +
   	'=' +
   	encodeURIComponent(product.category_id)+
	'&' +
   	encodeURIComponent('items[1][taxes][1][label]') +
   	'=' +
   	encodeURIComponent(product.taxe_label)+
	'&' +
   	encodeURIComponent('items[1][taxes][1][amount]') +
   	'=' +
   	encodeURIComponent(product.taxe_amount), "Jiwa Buy - Hipay", "");
 
	
 		}	
		}
	},
	isHidden:function(){
		if(this.model.getField('hidden') == true){
			return true;
		}else{
			return false;
		}
	},
	isRestricted:function(){
		if(this.model.getField('restricted') == true){
			return true;
		}else{
			return false;
		}
	},
	hiddenElement: function(){
		this.model.setDisplay(1);
	},
	displayElement:function(){
		this.model.setDisplay(0);
	},
	restrictElement:function(){
		this.model.setRestrict(1);
	},
	allowElement:function(){
		this.model.setRestrict(0);
	},
    updateTextCardDescription: function(){
        return {
            similar: tr('artist_infos_header'),
            play: tr('album_infos_button_playAll'),
            tools: tr('button_card_altmenu_edit_album')
        };
    },
    similar: function(){
        var artist = this.model.getField('artists').page;
        J.fc.gotoUrl('artist', artist[0].artistId);
    },
    play: function(id){
        if (id == undefined) {
            id = this.id;
        }
        if (id) {
            J.fc.getController("player", true).jwAddAlbum(id, {
                play: true
            });
        }
        
    },
	download: function(){
       
		
		if(this.model.getField('starzikUrl')){
			J.track('starzik', 'download','album');
       	 	window.open(this.model.getField('starzikUrl'), "Jiwa Download - StarZik", "");  
		}else if(this.model.getField('itunesUrl')){
			J.track('itunes', 'download','album');
       	 	window.open('http://clk.tradedoubler.com/click?p=23753&partnerId=2003&a=1570290&g=0&td_partnerId=2003&url=' + this.model.getField('itunesUrl'), "Jiwa Download - Itunes", "");  
		}else{
			 J.InfoBox.msg("Cet album n'est pas encore disponible en Téléchargement");
		}
		
		
        
    },
	  
    isExportable: function(){
        return true;
    },
    isFan: function(id){
        if (id == undefined) {
            id = this.id;
        }
        if (J.me.loggedIn) {
        
            if (J.me.AlbumsStore) {
                return J.me.AlbumsStore.getById(id);
            }
        }
        
        return false;
    },
    isRecommendate: function(){
        return this.model.getField("inRecommendation");
    },
	setRecommendation: function(){
		this.model.setRecommendate(1);
	},
	unsetRecommendation : function(){
		this.model.setRecommendate(0);
	},
    rename: function(id){
        if (id == undefined) {
            id = this.id;
        }
        
        return new J.Popup({
            title: tr('rename'),
            msg: tr('rename'),
            submit: {
                url: '/album/renamealbum',
                params: {
                    albumId: this.id
                }
            },
            trackController: 'album',
            trackAction: 'rename',
            big: true,
            success: this.afterAlbumEdit,
            scope: this,
            fields: [{
                type: 'field',
                inputType: 'text',
                fieldLabel: tr('rename'),
                name: 'albumName',
                value: this.model.getField("albumName")
            }]
        });
        
        
    },
    edit: function(){
    	
    	//Initilisation
    	var id = this.id;
    	var data = this.model.record.data;
    	var dateAlbumRelease = data.releaseDate.format(tr('formatDate'));
    	
    	return new J.Popup({
            title: tr('edit-album'),
            msg: tr('edit-album'),
            submit: {
                url: '/album/edit',
                params: {
                    albumId: this.id
                }
            },
            trackController: 'album',
            trackAction: 'edit-album',
            success: this.afterAlbumEdit,
            scope: this,
            tabs: [{title: 'General Options',
					items: [{
						type: 'text',
						fieldLabel: 'Album Name',
						name: 'albumName',
						value: data.albumName
					},
					{
						type: 'text',
						fieldLabel: 'Artist Name',
						name: 'artistName',
						readOnly: true,
						disabled: true,
						value: data.artistName
					},
					{
						type: 'text',
						fieldLabel: 'Artist Id',
						name: 'artistId',
						allowBlank: false,
						validationEvent: 'blur',
						value: data.artistId
					},
					{
						type: 'date',
						fieldLabel: 'Date Release',
						name: 'releaseDate',
						format: tr('formatDate'),
	                    emptyText: tr('formatDateEmpty'),
						allowBlank: true,
						showToday: false,
						validationEvent: 'blur',
						value: dateAlbumRelease
					},
					{
		               	type: 'checkboxgroup',
		                fieldLabel: '',
						hideLabel: true,
		                items: [
		                    {boxLabel: tr('trad_hearth'), name: 'inRecommendation', checked: data.inRecommendation},
		                    {boxLabel: tr('trad_hidden'), name: 'hidden', checked: data.hidden},
		                    {boxLabel: tr('trad_restricted'), name: 'restricted', checked: data.restricted}
						]
		            }]
	            },{
	            	title: 'Tags',
	            	items:[{
						type: 'textarea',
						fieldLabel: 'Tags',
						name: 'tags',
						allowBlank: true,
						validationEvent: 'blur',
						value: data.tags
					}]
	            },
				{
					title: 'Style Options',
					items:[{
						type: 'select',
						data: arrTr('themes'),
						name: 'style',
						fieldLabel: tr('select_themes_main'),
						value: data.style,
						validationEvent: 'blur'
					},{
						type: 'select',
						data: arrTr('themes'),
						name: 'styleSecondary',
						fieldLabel: tr('select_themes_secondary'),
						value: data.styleSecondary,
						validationEvent: 'blur'
					}]
				}]
    	})
    	
    },
	editGenre: function(id){
		if (id == undefined) {
            id = this.id;
        }
		data = this.model.record.data;
		return new J.Popup({
            title: tr('edit-genre'),
            msg: tr('edit-genre'),
            submit: {
                url: '/album/setstyle',
                params: {
                    albumId: this.id
                }
            },
            trackController: 'album',
            trackAction: 'edit-genre',
            success: this.afterAlbumEdit,
            scope: this,
            fields: [{
				type: 'select',
				data: arrTr('themes'),
				name: 'style',
				fieldLabel: tr('select_themes_main'),
				allowBlank: true,
				value: data.style,
				validationEvent: 'blur'
			},{
				type: 'select',
				data: arrTr('themes'),
				name: 'styleSecondary',
				fieldLabel: tr('select_themes_secondary'),
				allowBlank: true,
				value: data.styleSecondary,
				validationEvent: 'blur'
			}]
        });
	},
    setPicture: function(id){
        if (id == undefined) {
            id = this.id;
        }
        
        
        return new J.Popup({
            title: tr('playlist_popup_picture_title'),
            msg: tr('playlist_popup_picture_msg'),
            submit: {
                url: '/album/setpicture',
                params: {
                    albumId: this.id
                }
            },
            trackController: 'album',
            trackAction: 'setPicture',
            big: true,
            success: this.refresh,
            scope: this,
            fileUpload: true,
            fields: [{
                type: 'field',
                inputType: 'file',
                fieldLabel: tr('playlist_popup_picture_label_picture'),
                name: 'picture'
            }]
        });
        
        
    },
	isDownload: function(){

		
		if (!this.model.getField('starzikUrl') && !this.model.getField('itunesUrl')) {
			return false;	
		}else{
			return true;
		}
		
	},
    afterAlbumEdit: function(data){
        if (data) {
            this.model.update(data.edited.album);
        }
    }
});

J.Controller.News = Ext.extend( J.Controller.Card, {
	baseUrl : "news",
	defaultCategory : "comments",
	defaultInc :"biography",
	up: function(){
		this.model = new J.Model.News({controller : this });
		this.view = new J.View.News({controller : this });
	},
	create:function(){
		this.edit({},'Création',{url: '/news/create'});
	},
	edit:function(data,title,submit){
		
		if (data == undefined) {
			var data = this.model.record.data;
		}
		
		if (title == undefined) {
			title = "Edition : "+data.title;
		}	
		
		if (submit == undefined) {
			submit = {
				url: '/news/edit',
				params: {
					newsId: data.newsId
				}
			};
		}
		
		return new J.Popup({
			title: title,
			big:true,
			submit: submit,
			trackController: 'newsAdmin',
			trackAction: 'edit',
			success: this.afterNewsEdit,
			scope: this,
			tabs:[
					{	title:'Full',
						items:[{
							type: 'text',
           					anchor:'98%',
							fieldLabel: tr('title'),
							name: 'title',
							maxLength: '255',
							allowBlank: true,
							validationEvent: 'blur',
							value: data.title || ""
							},{
						
							type: 'html',
				            
				             anchor:'100%',
							height:300,
							hideLabel:true,
							name: 'text',
							allowBlank: true,
							validationEvent: 'blur',
							value: data.text|| ""
							},{
               	type: 'checkboxgroup',
                fieldLabel: '',
				hideLabel: true,
                items: [
                    {boxLabel: tr('isInternal'), name: 'isInternal', checked: data.isInternal}
				]
            },{
								type: 'select',
								fieldLabel: tr('state'),
								data: arrTr('news_state'),
								name: 'state',
								value: data.state
							}]
					},{
						title:'Abstract',
						items:[{
							type: 'html',
				            anchor:'100%',
							height:300,
							hideLabel:true,
							name: 'thread',
							allowBlank: true,
							validationEvent: 'blur',
							value: data.thread|| ""
							}]
					},{
						title:'Data',
						items:[{
								type: 'select',
								fieldLabel: 'Type',
								data: arrTr('news_type'),
								name: 'type',
								value: data.type
							},{
								type: 'text',
								fieldLabel: 'Identifiant',
								name: 'objId',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.objId
							},{
								type: 'select',
								fieldLabel: 'Type de propiétaire',
								data: arrTr('news_type'),
								name: 'ownerType',
								value: data.ownerType
							},{
								type: 'text',
								fieldLabel: 'Identifiant du propriétaire',
								name: 'ownerId',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.ownerId
							},{
								type: 'select',
								fieldLabel: ' Mode d\'Affichage',
								data: arrTr('box_template'),
								name: 'format',
								value: data.format
							}]
					},{
						title:'Location',
						items:[{
								type: 'textarea',
								fieldLabel: 'Tags',
								style: 'height: 50px',
								name: 'tags',
								maxLength: '255',
								allowBlank: true,
								maskRe: "/,/",
								preventScrollbars: true,
								grow: false,
								value: data.tags|| ""
							}]
					},{
						title:'Source',
						items:[{
								type: 'select',
								data: arrTr('news_provider'),
								name: 'provider',
								fieldLabel: tr('provider'),
								value: data.provider
							},{
								type: 'select',
								data: arrTr('wikipedia_languages'),
								name: 'languageId',
								fieldLabel: tr('language'),
								value: data.languageId
							},
							{
			                    type: 'date',
			                    fieldLabel: "Date",
			                    name: 'publishDate',
			                    format: 'Y-m-d H:i:s',
			                    value: data.publishDate
			                },{
								type: 'text',
								fieldLabel: tr('linkUrl'),
								name: 'linkUrl',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.linkUrl 
							}]
					},{
						title:'Edito',
						items:[{
								type: 'text',
								fieldLabel: tr('edito_title'),
								name: 'editoTitle',
								allowBlank: true,
								maxLength: '255',
								validationEvent: 'blur',
								value: data.editoTitle
							},{
								type: 'text',
								fieldLabel: tr('edito_subtitle'),
								name: 'editoSubTitle',
								allowBlank: true,
								maxLength: '255',
								validationEvent: 'blur',
								value: data.editoSubTitle
							},{
								type: 'text',
								fieldLabel: tr('edito_link'),
								name: 'editoLink',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.editoLink 
							},{
								type: 'text',
								fieldLabel: tr('edito_link_name'),
								name: 'editoLinkName',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.editoLinkName 
							},{
								type: 'text',
								fieldLabel: tr('edito_trackid'),
								name: 'editoTrackId',
								allowBlank: true,
								validationEvent: 'blur',
								value: data.editoTrackId 
							},{
			               	type: 'checkboxgroup',
			                fieldLabel: '',
							hideLabel: true,
			                items: [
			                    {boxLabel: tr('isReady'), name: 'editoIsReady', checked: data.editoIsReady}
							]
			            	}]
					}
					]
		});
			
	
	},
	setPicture :function(data){
		if(data == undefined){
			var data = this.model.record.data;
		}
		
		
		return new J.Popup({
				title: tr('news_popup_picture_title'),
				submit: {url: '/news/setpicture',
				params: {
					newsId: data.newsId
					}
				},
				trackController: 'news',
				trackAction: 'setPicture',
				big:true,
				success: this.refresh,
				scope: this,
				fileUpload: true,
				fields:
				[
					{
						type: 'field',
						inputType: 'file',
						fieldLabel: 'Image de l\'article',
						name: 'picture'
					}
				]
			});
		
	},
	setPictureFocus :function(data){
		
		if(data == undefined){
			var data = this.model.record.data;
		}
		
		
		return new J.Popup({
				title: tr('news_popup_picture_title'),
				submit: {url: '/news/setpicture',
				params: {
					newsId: data.newsId,
					focus :true
					}
				},
				trackController: 'news',
				trackAction: 'setPicture',
				big:true,
				success: this.refresh,
				scope: this,
				fileUpload: true,
				fields:
				[
					{
						type: 'field',
						inputType: 'file',
						fieldLabel: 'Image Focus',
						name: 'picture'
					}
				]
			});
		
	},
	afterNewsEdit :function(data){
		if (J.fc.grid) {
			if (J.fc.grid.store) {
				J.fc.grid.store.reload();
				return;
			}
		}
		
		if(data){
			this.model.update(data.edited.news);
		}
	}
});J.Controller.Playlist = Ext.extend(J.Controller.Card, {
	baseUrl : "playlist",
	defaultCategory : "tracks",	
	defaultInc :"",
	addtracks:false,
	up: function(){
	
	this.model = new J.Model.Playlist({controller : this });
	
	this.view = new J.View.Playlist({controller : this });
	},
	updateTextCardDescription:function(){
		return text = {
			similar: tr('button_card_altmenu_view_jiwer'),
			play: tr('playlist_infos_button_playAll'),
			tools: tr('edit_playlist')
		};
		
	},
	similar:function(){
		var userId = this.model.getField('ownerId');
		J.fc.gotoUrl('user',userId);
	},
	play :function(id){
		if(id == undefined){
			id  = this.id;
		}
			if(name == undefined){
			name  = this.model.getField('playlistName');
		}
			
	/*	J.fc.getController("player", true).jwPlayRadio(id,name ,'playlist');
		*/
		
		J.fc.getController("player", true).jwAddPlaylist(id, {
				play: true
			});
	
	
	},
	isExportable: function() {
		return true;
	},
	isRecommendate: function(){
        return this.model.getField("inRecommendation");
    },
	setRecommendation: function(){
		this.model.setRecommendate(1);
	},
	unsetRecommendation : function(){
		this.model.setRecommendate(0);
	},
	create:function(){
		this.edit({},tr('playlist_popup_create_title'),{url: '/playlist/create'});
	},
	edit:function(data,title,submit,addtracks){
		
		if (addtracks != undefined) {
			this.addtracks = addtracks;
		}
		
		if(data == undefined){
			data = this.model.record.data;
			title = "Edition :"+data.playlistName;
			submit = {
				url: '/playlist/edit',
				params: {
					playlistId: this.id
				}
			};
		}
		
		new J.Popup({
			title: title,
			msg: tr('playlist_popup_create_msg'),
			submit: submit,
			success: this.afterPlaylistEdit,
			trackController: 'myPlaylist',
			trackAction: 'edit',
			scope: this,
			requireLogin: true,
			armEnter: false,
			fields: [{
				type: 'text',
				fieldLabel: tr('playlist_popup_create_label_name'),
				name: 'playlistName',
				maxLength: '80',
				allowBlank: false,
				value: data.playlistName
			}, {
				type: 'text',
				fieldLabel: tr('folder'),
				name: 'playlistFolder',
				maxLength: '80',
				allowBlank: true,
				value: data.playlistFolder
			}, {
				type: 'select',
				data: arrTr('themes'),
				name: 'style',
				fieldLabel: tr('select_themes'),
				allowBlank: true,
				value: data.style,
				validationEvent: 'blur'
			}, {
				type: 'textArea',
				fieldLabel: tr('playlist_popup_create_label_description'),
				name: 'description',
				style: 'height: 50px',
				maxLength: '80',
				allowBlank: true,
				value: data.description
			}, {
				type: 'textArea',
				fieldLabel: tr('playlist_popup_create_label_tags'),
				style: 'height: 50px',
				name: 'tags',
				maxLength: '255',
				allowBlank: true,
				maskRe: "/,/",
				preventScrollbars: true,
				grow: false,
				value: data.tags
			}, {
				type: 'checkbox',
				name: 'private',
				hideLabel: true,
				id: 'create-playlist-public',
				fieldLabel: '',
				width: 200,
				boxLabel: tr('private'),
				labelSeparator: '',
				validationEvent: false,
				checked	: this.model.getField('private')
			}]
		
		});
	},
	remove :function(){
		
		
		Ext.Msg.show({
				title: tr('playlist_popup_delete_title'),
				msg: tr('playlist_popup_delete_msg'),
				buttons: Ext.Msg.YESNOCANCEL,
				fn: function(btn) {
					if(btn=="yes") {
						
						this.model.reqDelete();
						
					}
				},
				icon: Ext.MessageBox.QUESTION,
				scope: this
			});
		
		
		
	},
	setPicture :function(id){
		if(id == undefined){
			id  = this.id;
		}
		
		
		return new J.Popup({
				title: tr('playlist_popup_picture_title'),
				msg: tr('playlist_popup_picture_msg'),
				submit: {
					url: '/playlist/setpicture', 
					params: {
						playlistId: this.id
					}
				},
				trackController: 'myPlaylist',
				trackAction: 'setPicture',
				big:true,
				success: this.refresh,
				scope: this,
				fileUpload: true,
				fields:
				[
					{
						type: 'field',
						inputType: 'file',
						fieldLabel: tr('playlist_popup_picture_label_picture'),
						name: 'picture'
					}
				]
			});
		
		
	},
	
	isFan : function(id){
		if(id == undefined){
			id  = this.id;
		}
		if(J.me.loggedIn){
		
			if (J.me.favoritePlaylistsStore) {
				return J.me.favoritePlaylistsStore.getById(id);
			}
		}
		
		return false;
	},
	afterPlaylistEdit :function(data){
		
		if(data){
		
			if(this.id == data.edited.playlist.playlistId){
				this.model.update(data.edited.playlist);
			}	
			
			
			if(this.addtracks){
				J.fc.getController('playlistAdder',true).afterPlaylistCreate(data);
			}
			
			
			
			J.me.updatePlaylistTreeRoot(data.myplaylists);
		}
		
		this.addtracks =false;
	
	},

	mine : function(){	
	
		J.Controller.Playlist.superclass.constructor.call(this);
		
		if (J.me.isLoggedIn()) {
			if(this.model.getField('ownerId') == J.me.userId || isStaff() ){
				return true;
			}else{			
				return false;
			}
		}	
	}
});
J.Controller.Station = Ext.extend( J.Controller.Card, {
	baseUrl : "station",
	defaultCategory : "comments",	
	defaultInc :"artists",
	up: function(){
	
		this.model = new J.Model.Station({controller : this });
		
		this.view = new J.View.Station({controller : this });
		
		
	},
	isFan : function(id){
		if(id == undefined){
			id  = this.id;
		}
		
		if(J.me.loggedIn){
		
			if (J.me.RadiosStore) {
				return J.me.RadiosStore.getById(id);
			}
		}
		
		return false;
	},
	updateTextCardDescription:function(){
		return text = {
			similar: tr('button_card_altmenu_view_dj'),
			play: tr('button_card_altmenu_lunch_radio'),
			tools: tr('button_card_altmenu_edit_radio')
		};
	},
	similar:function(){
		var userId = this.model.getField('radioOwnerId');
		var userName = this.model.getField('radioOwnerName');
		J.fc.gotoUrl('user',userId);
	},
	play :function(id,name){
		if(id == undefined){
			id  = this.id;
		}
		if(name == undefined){
			name  = this.model.getField('radioName');
		}
		J.fc.getController("player", true).jwPlayRadio(id,name ,'radio');
			
		
	},	
	remove :function(){
		
		
		Ext.Msg.show({
				title: tr('radio_popup_delete_title'),
				msg: tr('radio_popup_delete_msg'),
				buttons: Ext.Msg.YESNOCANCEL,
				fn: function(btn) {
					if(btn=="yes") {
						
						this.model.reqDelete();
						
					}
				},
				icon: Ext.MessageBox.QUESTION,
				scope: this
			});
		
		
		
	},
	setPicture: function(id){
        if (id == undefined) {
            id = this.id;
        }
        
        
        return new J.Popup({
            title: tr('radio_popup_picture_title'),
            msg: tr('radio_popup_picture_msg'),
            submit: {
                url: '/radio/setpicture',
                params: {
                    radioId: this.id
                }
            },
            trackController: 'radio',
            trackAction: 'setPicture',
            big: true,
            success: this.refresh,
            scope: this,
            fileUpload: true,
            fields: [{
                type: 'field',
                inputType: 'file',
                fieldLabel: tr('playlist_popup_picture_label_picture'),
                name: 'picture'
            }]
        });
        
        
    }
});

J.Controller.Track = Ext.extend( J.Controller.Card, {
	baseUrl : "track",
	defaultCategory : "suggestions",	
	defaultInc :"details",
	up: function(){
	
	this.model = new J.Model.Track({controller : this });
	
	this.view = new J.View.Track({controller : this });
	},
	isExportable: function(){
    
        return true;
    },
	isHidden:function(){
		if(this.model.getField('hidden') == true){
			return true;
		}else{
			return false;
		}
	},
	isRestricted:function(){
		if(this.model.getField('restricted') > 0){
			return true;
		}else{
			return false;
		}
	},
	hiddenElement: function(){
		this.model.setDisplay(1);
	},
	displayElement:function(){
		this.model.setDisplay(0);
	},
	restrictElement:function(){
		this.model.setRestrict(1);
	},
	allowElement:function(){
		this.model.setRestrict(0);
	},
	play :function(id){
		
		 if (id == undefined) {
		            id = this.id;
		 }
			  
		 if (id) {
		            J.fc.getController("player", true).jwAddTrack(id, {
		                play: true
		            });
		}
		

	},
	updateTextCardDescription:function(){
		return text = {
			similar: tr('goto_artist_card'),
			play: tr('trackGrid_tip_play'),
			tools: tr('button_card_altmenu_edit_track')
		};
	},
	similar:function(){
		var artistId = this.model.getField('artistId');
		J.fc.gotoUrl('artist',artistId);
	},
	remove :function(){
		
		
		Ext.Msg.show({
				title: tr('playlist_popup_delete_title'),
				msg: tr('playlist_popup_delete_msg'),
				buttons: Ext.Msg.YESNOCANCEL,
				fn: function(btn) {
					if(btn=="yes") {
						
						this.model.reqDelete();
						
					}
				},
				icon: Ext.MessageBox.QUESTION,
				scope: this
			});
		
		
		
	},
	isDownload: function(track){
		
		if(track == undefined){
			track ={};
			track.itunesTrackUrl = this.model.getField('itunesTrackUrl');
			
			track.starzikTrackUrl = this.model.getField('starzikTrackUrl');
		}
		

		
		if (!track.starzikTrackUrl && !track.itunesTrackUrl) {
			return false;	
		}else{
			return true;
		}
		
	},
	suggest : function(track){
		if(track ==undefined){
			
			track = this.model.record.data;
		}
		
		if(track){
			
				
			new J.Popup({
				title : tr('suggestion_popup_header'),
				requireLogin : true,
				// request: {url:'/artist/wikipedia/get', params: {artistId:
				// this.artistId, languageId: 0}},
				msg : tr('suggestion_popup_msg', track.artistName
						.bold(), track.songName.bold()),
				bottomMsg : tr('suggestion_popup_bottomMsg'),
				submit : {
					url : '/track/suggest',
					params : {
						trackId : track.trackId
					}
				},
				success : this.respSuggest,
				trackController : 'track',
				trackAction : 'suggest',
				scope : this,
				fields : [{
					type : 'textArea',
					fieldLabel : tr('suggestion_popup_label_message'),
					name : 'text',
					maxLength : '255'
				}]
			});
			
			
		}
	
	},
	widget:function(){
		J.WizardSong.show({trackId:J.Seo.trackId, permalink : J.Seo.artistLink, name:J.Seo.artistName});
	},
	download: function(){
   
   				
		if(this.model.getField('starzikTrackUrl')){
			J.track('starzik', 'download','album');
       	 	window.open(this.model.getField('starzikTrackUrl'), "Jiwa Download - StarZik", "");  
		}else if(this.model.getField('itunesTrackUrl')){
			J.track('itunes', 'download','track');
       	 	window.open('http://clk.tradedoubler.com/click?p=23753&partnerId=2003&a=1570290&g=0&td_partnerId=2003&url=' + this.model.getField('itunesTrackUrl'), "Jiwa Download - Itunes", "");  
		}else{
			 J.InfoBox.msg("Ce titre n'est pas encore disponible en téléchargement");
		}
		
        
    },
    edit: function(id){
    	if (id == undefined) {
            id = this.id;
        }
    	
        	
    	data = this.model.record.data;
    	
    	return new J.Popup({
            title: tr('edit-track'),
            msg: tr('edit-track'),
            submit: {
                url: '/track/edit',
                params: {
                    trackId: this.id
                }
            },
            trackController: 'track',
            trackAction: 'edit-track',
            success: this.afterSetStyle,
            scope: this,
            tabs: [{
					title: 'General Options',
					items: [{
							type: 'text',
							fieldLabel: 'Song Id',
							name: 'songId',
							value: data.songId,
							hidden: true,
							hideLabel: true
					},{
							type: 'text',
							fieldLabel: 'Track Name',
							name: 'songName',
							allowBlank: false,
							validationEvent: 'blur',
							value: data.songName
						},
						{
							type: 'text',
							fieldLabel: 'Artist Name',
							name: 'artistName',
							readOnly: true,
							disabled: true,
							value: data.artistName
						},
						{
							type: 'text',
							fieldLabel: 'Artist Id',
							name: 'artistId',
							allowBlank: false,
							validationEvent: 'blur',
							value: data.artistId
						},
						{
							type: 'text',
							fieldLabel: 'Album Name',
							name: 'albumName',
							readOnly: true,
							disabled: true,
							value: data.albumName
						},
						{
							type: 'text',
							fieldLabel: 'Album Id',
							name: 'albumId',
							allowBlank: false,
							validationEvent: 'blur',
							value: data.albumId
						},{
							type: 'text',
							fieldLabel: 'Duration',
							name: 'duration',
							allowBlank: true,
							validationEvent: 'blur',
							value: data.duration
						},
						{
							type: 'text',
							id: 'ituneTrackUrlForm',
							fieldLabel: 'Itune Url',
							name: 'itunesTrackUrl',
							allowBlank: true,
							validationEvent: 'blur',
							readOnly: true,
							disabled: true,
							value: data.itunesTrackUrl
						},
						{
							type: 'text',
							id: 'starzikTrackUrlForm',
							fieldLabel: 'Starzik Url',
							name: 'starzikTrackUrl',
							allowBlank: true,
							validationEvent: 'blur',
							readOnly: true,
							disabled: true,
							value: data.starzikTrackUrl
						},
						{
			               	type: 'checkboxgroup',
			                fieldLabel: '',
							hideLabel: true,
			                items: [
			                    {boxLabel: tr('trad_hidden'), name: 'hidden', checked: data.hidden},
			                    {boxLabel: tr('trad_restricted'), name: 'restricted', checked: data.restricted}
							]
			            }]
                },
				{
					title: 'Style Options',
					items:[{
						type: 'select',
						data: arrTr('themes'),
						name: 'style',
						fieldLabel: tr('select_themes_main'),
						value: data.style,
						validationEvent: 'blur'
					},{
						type: 'select',
						data: arrTr('themes'),
						name: 'styleSecondary',
						fieldLabel: tr('select_themes_secondary'),
						value: data.styleSecondary,
						validationEvent: 'blur'
					}]
				}]
    	});
    },
	editGenre: function(id){
		if (id == undefined) {
            id = this.id;
        }
		data = this.model.record.data;
		return new J.Popup({
            title: tr('edit-style'),
            msg: tr('edit-style'),
            submit: {
                url: '/track/setstyle',
                params: {
                    trackId: this.id
                }
            },
            trackController: 'track',
            trackAction: 'edit-style',
            success: this.afterSetStyle,
            scope: this,
            fields: [{
				type: 'select',
				data: arrTr('themes'),
				name: 'style',
				fieldLabel: tr('select_themes_main'),
				value: data.style,
				validationEvent: 'blur'
			},{
				type: 'select',
				data: arrTr('themes'),
				name: 'styleSecondary',
				fieldLabel: tr('select_themes_secondary'),
				value: data.styleSecondary,
				validationEvent: 'blur'
			}]
        });
	},
	addToNewPlaylist: function(track){
		
		if(this.model.getField('restricted')==2){
			return;
		}
		
		if(track ==undefined){
			track = this.model.record.data;
		}
		
		if (track) {
		
			J.fc.getController("playlistAdder", true).create({
				records: [track]
			});
		}
	},
	addToPlaylist: function(track){
		
		if(this.model.getField('restricted')==2){
			return;
		}
		
		if(track ==undefined){
			track = this.model.record.data;
		}
		
		if (track) {
		
			J.fc.getController("playlistAdder", true).show({
				records: [track]
			});
			
		}
		
	},
	addToPlayer:function(track){
		
		if(this.model.getField('restricted')==2){
			return;
		}
		if(track ==undefined){
			track = this.model.record.data;
		}
		
		
		if (track) {
			
			J.fc.getController("player", true).jwAddTracks([track], {
				play: false
			});
			
		}
		
	},
    afterSetStyle: function(data){
        if (data) {
            this.model.update(data.edited.track);
       
        }
    }
});



J.Controller.User = Ext.extend(J.Controller.Card, {
    baseUrl: "user",
    defaultCategory: "comments",
    defaultInc: "details",
    up: function(){
    
        this.model = new J.Model.User({
            controller: this
        });
        
        this.view = new J.View.User({
            controller: this
        });
        
    },
    isFan: function(id){
        if (id == undefined) {
            id = this.id;
        }
        if (J.me.loggedIn) {
        
            if (J.me.AngelStore) {
                return J.me.AngelStore.getById(id);
            }
        }
        
        return false;
    },
	isRecommendate: function(){
        return this.model.getField("inRecommendation");
    },
	setRecommendation: function(){
		this.model.setRecommendate(1);
	},
	unsetRecommendation : function(){
		this.model.setRecommendate(0);
	},
    play: function(id, name){
        if (id == undefined) {
            id = this.id;
        }
        
        if (name == undefined) {
            name = this.model.getField('userName');
        }
        
        J.fc.getController("player", true).jwLaunchSimiliRadio(id, name, 'user');
        
    },
    mine: function(){
        J.Controller.User.superclass.constructor.call(this);
        if (this.model.userId == J.me.userId || isStaff()) {
            return true;
        }
        else {
            return false;
        }
    },
    updateTextCardDescription: function(id, div){
        return text = {
            similar: tr('universe_profile_button_write'),
            play: tr('button_card_altmenu_jiwer_smartradio'),
            tools: tr('universe_profile_button_edit')
        };
    },
    similar: function(){
        this.message();
    },
    message: function(){
        if (this.id) {
            return new J.Popup({
                title: tr('universe_profile_button_write'),
                submit: {
                    url: '/user/outboxsend'
                },
                trackController: 'user',
                trackAction: 'send',
                requireLogin: true,
                autoHeight: true,
                success: this.afterUserMessage,
                scope: this,
                armEnter: false,
                fields: [{
                    type: 'text',
                    fieldLabel: tr('newMail_label_recipients'),
                    name: 'recipientsNames',
                    allowBlank: false,
                    readOnly: true,
                    value: this.model.getField('userName')
                }, {
                    type: 'text',
                    fieldLabel: tr('newMail_label_subject'),
                    name: 'subject',
                    allowBlank: true,
                    maxLength: 100,
                    value: ''
                }, {
                    type: 'textArea',
                    fieldLabel: tr('newMail_label_body'),
                    name: 'body',
                    style: 'height: 150px',
                    allowBlank: false,
                    value: ''
                }]
            });
            
        }
        
        
    },
	remove :function(){
		
		
		Ext.Msg.show({
				title: tr('user_popup_delete_title'),
				msg: tr('user_popup_delete_msg'),
				buttons: Ext.Msg.YESNOCANCEL,
				fn: function(btn) {
					if(btn=="yes") {
						this.model.reqDelete();
					}
				},
				icon: Ext.MessageBox.QUESTION,
				scope: this
			});
		
		
		
	},
    edit: function(){
        if (this.id) {
            if (J.me.getField('bornDate')) {
                var dt = Date.parseDate(J.me.getField('bornDate'), "Y-m-d");
                var date = dt.format(tr('formatDate'));
            }
            else {
                var date = "";
            }
            
            return new J.Popup({
                title: tr('user_popup_profile_title'),
                msg: tr('user_popup_profile_msg'),
                submit: {
                    url: '/user/edit'
                },
                trackController: 'myUniverse',
                trackAction: 'profile',
                success: this.afterUserEdit,
                scope: this,
                fields: [{
                    type: 'select',
                    data: arrTr('sex'),
                    displayField: 'sexName',
                    name: 'sex',
                    fieldLabel: tr('user_popup_profile_label_sex'),
                    //allowBlank: false,
                    //validationEvent: 'blur',
                    value: J.me.getField('sex')
                }, {
                    type: 'date',
                    fieldLabel: tr('user_popup_signup_label_bornDate'),
                    name: 'bornDate',
                    format: tr('formatDate'),
                    value: date,
                    emptyText: tr('formatDateEmpty'),
                    showToday: false,
                    allowBlank: false,
                    validationEvent: 'blur'
                }, {
                    type: 'select',
                    fieldLabel: tr('user_popup_profile_label_country'),
                    data: arrTr('countries'),
                    name: 'countryId',
                    value: J.me.getField('countryId')
                }, {
                    type: 'text',
                    fieldLabel: tr('user_popup_profile_label_town'),
                    name: 'town',
                    maxLength: '80',
                    allowBlank: true,
                    validationEvent: 'blur',
                    value: J.me.getField('town') || ""
                }, {
                    fieldLabel: tr('user_popup_signup_label_postalCode'),
                    type: 'text',
                    name: 'postalCode',
                    allowBlank: true,
                    validationEvent: 'blur',
                    value: J.me.getField('postalCode') || ""
                }, {
                    type: 'text',
                    fieldLabel: tr('user_popup_profile_label_languages'),
                    name: 'languages',
                    maxLength: '255',
                    allowBlank: true,
                    validationEvent: 'blur',
                    value: J.me.getField('languages') || ""
                }, {
                    type: 'select',
                    fieldLabel: jTr('user_popup_profile_label_interestedIn', J.me.record.data),
                    data: arrTr('interestedIn'),
                    name: 'interestedIn',
                    allowBlank: true,
                    value: J.me.getField('interestedIn')
                }, {
                    type: 'select',
                    fieldLabel: jTr('user_popup_profile_label_relationshipStatus', J.me.record.data),
                    data: arrTr('relationshipStatus'),
                    name: 'relationshipStatus',
                    allowBlank: true,
                    value: J.me.getField('relationshipStatus')
                }, {
                    type: 'textArea',
                    fieldLabel: tr('user_popup_profile_label_tastes'),
                    name: 'tastes',
                    maxLength: '200',
                    allowBlank: true,
                    validationEvent: 'blur',
                    value: J.me.getField('tastes') || ""
                }, {
                    type: 'radiogroup',
                    fieldLabel: 'Acceptez vous de recevoir des offres de nos partenaires ? ',
                    items: [{
                        boxLabel: "Oui",
                        name: 'partnerContact',
                        inputValue: 1,
                        checked: J.me.getField('partnerContact')
                    }, {
                        boxLabel: "Non",
                        name: 'partnerContact',
                        inputValue: 0,
                        checked: !J.me.getField('partnerContact')
                    }]
                }, {
                    type: 'radiogroup',
                    fieldLabel: 'Acceptez vous de recevoir des newsletter jiwa ? ',
                    items: [{
                        boxLabel: "Oui",
                        name: 'newsletterContact',
                        inputValue: 1,
                        checked: J.me.getField('newsLetterContact')
                    }, {
                        boxLabel: "Non",
                        name: 'newsletterContact',
                        inputValue: 0,
                        checked: !J.me.getField('newsLetterContact')
                    }]
                }]
            });
            
        }
    },
    afterUserEdit: function(data){
        if (data) {
            this.model.update(data.edited.user);
            J.me.update(data.edited.user);
        }
    },
    afterUserMessage: function(data){
    
        if (data) {
            J.InfoBox.msg(tr("abgrabber_success_msg"));
        }
        
    },
    setPicture: function(){
    
        return new J.Popup({
            title: tr('universe_popup_image_title'),
            msg: tr('universe_popup_image_msg', this.nbInvitations),
            submit: {
                url: '/user/setpicture'
            },
            trackController: 'myUniverse',
            trackAction: 'setPicture',
            //trackId: this.playlistId,
            success: this.refresh,
            scope: this,
            big: true,
            fileUpload: true,
            requireLogin: true,
            fields: [{
                type: 'field',
                fieldLabel: tr('playlist_popup_picture_label_picture'),
                name: 'picture',
                inputType: 'file'
            }]
        });
        
    },
    popupAccessDenied: function(oUserGrantedAccess){
        return new J.Popup({
            title: tr("title_access_denied"),
            msg: tr('user_popup_login_msg_withGoal'), //tr('user_popup_login_msg_withoutGoal')),
            trackController: 'user',
            trackAction: 'AccessFailed',
            scope: this,
            fields: [{
                type: 'textArea',
                name: 'message',
                allowBlank: false,
                value: tr("content_access_denied").first + oUserGrantedAccess.code +tr("content_access_denied").second+oUserGrantedAccess.ip + tr("content_access_denied").third,
				hideLabel : true,
				readOnly : true, 
				width: 480,
				height : 220
            }]
        });
    },
    popupSupporter: function(){
        return new J.Popup({
            title: tr('support_jiwa'),
            submit: {
                url: '/user/allopass'
            },
			success: function(data){
	            
				Ext.Msg.alert('Jiwa',
				"Merci pour votre soutien ! "+
				"<br />La mention \"Jiwa Addict\" figure maintenant sur votre profil. "+
				"<br />Merci de vous inscrire et de vous connecter si ce n'est pas encore fait afin que votre code soit pris en compte.");
			
			J.CookieProvider.set("warner", "ok");
			if (data.edited){
				if (data.edited.user) {
	 				J.fc.getController('user', true).afterUserEdit(data);
				}
			}
			
			
			
			},
            trackController: 'myUniverse',
            trackAction: 'supporter',
            scope: this,
			msg :"<b style='font-size:14px'>Avec notre partenaire Allopass, devenez Jiwa Addict, soutenez votre site de musique préféré et recevez des offres en exclusivité et en avant première !" +
			"<br />" +
			"<br />Par SMS, pour obtenir votre code, envoyez CODE au 81 038 </b>(3,00 euros par envoi prix d'un SMS, 1 envoi de SMS par code d'acces sms)" +
			"<br /><b style='font-size:14px'>ou appelez le : 08 99 78 46 66 </b>(seul le cout de la communication vous sera facture 1,91 euros l'appel a partir d'un poste fixe audio) <br /><br /><br />",
            big: true,
            fields: [{
                type: 'text',
                fieldLabel: "<b>Entrez votre code</b>",
                name: 'allopass',
                validationEvent: 'blur'
            }]
        });
    },
	showGame: function(){
		
		var win = new Ext.Window({
        // constrain: true,
		style:"background:#FFFFFF url(/res/img/home/ipad.jpg) no-repeat 0 -20px;",
        cls: 'popup',
        closable: false,
        resizable: false,
        draggable: true,
        width: 900,
		height: 460,
        modal: true,
        frame: true,
		items: {
			style:'padding: 15px;',
			html: 
					'<div style="color:#333333;height:40px;font-size:34px;margin-bottom:3px;text-align:center;width:500px;">Gagnez un <strong>iPad</strong></div>'+
					'<div style="color:#666666;font-size:16px;height:26px;text-align:center;width:500px;">Un gagnant tous les <em>989</em> codes</div>'+
					'<div style="margin-top:10px;border:#EEEEEE solid 1px;width:250px;padding:10px 0px 3px 10px;">'+
						'<div style="margin-bottom:10px;color:#666666;font-size:16px;height:20px;"><u>1 - Obtenez un Code</u></div>'+
						'<div style="margin-right:20px;color:#666666;font-size:12px;height:20px;">Par téléphone au <font color="#d70978"><b>08 99 69 00 15</b></font>* </div>'+
						'<div style="margin-right:20px;color:#666666;font-size:12px;height:20px;">Par SMS envoyez <font color="#0368b8"><b>CODE</b></font> au <font color="#0368b8"><b>81038</b></font>** </div>'+
					'</div>'+
					'<div style="margin-top:10px;border:#EEEEEE solid 1px;width:250px;padding:10px 0px 15px 10px;">'+
						'<div style="margin-bottom:10px;color:#666666;font-size:16px;height:20px;"><u>2 - Utilisez votre Code</u></div>'+
						'<div style="margin-right:20px;color:#666666;font-size:12px;height:20px;">Entrez votre code :</div>'+
						'<div style="margin-right:20px;color:#666666;font-size:12px;">'+
							'<table><tr><td><input style="margin-right:5px;width:112px;" type="text" id="game-code" class="champ"></td><td> <div style="text-align:center;border:#000000 solid 1px;background-color:#EEEEEE;width:80px;padding:1px;" onClick="J.fc.getController(\'user\', true).model.validGame(document.getElementById(\'game-code\').value);">Valider</div></td></tr></table>'+
						'</div>'+
					'</div>'+
					'<div style="margin-top:10px;border:#EEEEEE solid 1px;width:250px;padding:10px 0px 10px 10px;">'+
					'<div style="color:#666666;text-align:left;font-size:12px;" >- <a href="/res/pdf/Reglement.pdf" id="game-result" style="color:#666666;">Télécharger le réglement</a></div>'+
				'</div>'+
				'<div style="width:800px;padding:10px 0px 10px 10px;">'+
					'<div  style="color:#666666;margin-top:20px; margin-right: 5px;font-size:10px;">* seul le cout de la communication vous sera facturé 1,91 euros l\'appel à partir d\'un poste fixe audio<br/>** 3,00 euros par envoi prix d\'un SMS, 1 envoi de SMS par code d\'accés sms</div>'+
				'</div>'
					
			},
        hideAds: true,
        layout: 'fit',
        shadow: false,
        buttonAlign: 'center',
        buttons: [
           {
                text: "Accédez à Jiwa.fr",
                scope: this,
                handler: function(){
					win.close();
					
					J.CookieProvider.set("ipad-1", "ok");
				}
           }],
        y: 50
      
    });
	
	win.show();
	
	
    
    },
	showPromo: function(){
		
		J.fc.promo = new Ext.Window({
        // constrain: true,
		style:"background:#FFFFFF no-repeat 0 0px;",
        cls: 'popup',
        closable: false,
        resizable: false,
        draggable: true,
        width: 900,
		height: 420,
        modal: true,
		bodyStyle:'padding:0;margin:0;',   
		     frame: true,
		items: {
			style:'margin-bottom:3px;text-align:left;',
			html: 
			'<div style="padding: 10px 0 0 15px;margin-top:30px;width:300px;float:left;">'+
			'<img src="http://medias.jiwa.fm/album/300/353683.jpg"  width="300" height="300" />'
			+'</div>'+
			'<div style="padding: 10px 0 0 15px;margin-top:10px;width:320px;float:left;">'+
					'<div style="color:#303030;font-size:12px;font-weight:bold;height:13px;line-height:12px;">John & Jehn</div>'+
					'<div style="color:#7f0411;font-size:24px;height:24px;line-height:24px;">Time For The Devil</div>'+
					'<div style="margin-top:15px;margin-bottom:5px;color:#303030;font-size:11px;">'+
					'John & Jehn forment un duo particulièrement talentueux s\'exprimant dans une Pop envoutante et un Rock aux riffs détonants !<br/>'+
'Entrez dans l\'univers hypnotisant de leur premier album : Time For The Devil, composé de 15 titres desquels jaillissent les influences New Wave de groupes anglais des années 80 à l\'instar de Joy Division Tears For Fears et Depeche Mode.<br/>'+
'Porté par les singles Time For The Devil, Oh My Love et Shy, l\'album se présente comme un mariage réussi entre les claviers, la voix Pop aérienne de Jehn et la guitare Rock de John.<br/>'+
	'<br/>'+
'Jiwa en a déjà fait son Coup de Cœur !<br/>'+
		'</div>'+
					'<div style="margin-top:10px;font-size:13px;border:#7b0403 solid 1px;background-color:#e7e7e7;padding:3px;">'+
'<span style="color:#7b0403">Téléchargez l\'album <span style="font-weight:bold;">Time For The Devil en mp3 320kbps</span> pour 9.99€ seulement </span>et profitez  en <span style="font-weight:bold;">bonus </span> de Lookin For You et Sunny Boy,<span style="font-weight:bold;"> 2 titres inédits exclusifs !</span><br/>'+
					'</div>'+
				'<div style="padding-top: 10px;padding-left: 10px;width: 300px; height:80px;">'+
				'<div  style="background:url(\'/res/img/home/buy.gif\') no-repeat 0 0;height:50px;width:125px;float:left;"  onclick="J.fc.getController(\'album\',true).buy(353683,\'John & Jehn - Time For The Devil\')" /></div>'+
				'<div style="background:url(\'/res/img/home/button.png\') no-repeat 0 0;color:#FFFFFF;height:30px;padding-left:40px;padding-top:10px;width:120px;float:right;" onclick="J.fc.promo.close();J.CookieProvider.set(\'promo-1\', \'ok\');">Accédez à Jiwa.fr</div>'+
				'</div>'+
				
				'</div>'+
				'<div style="margin-top:40px;padding-left:25px;width: 200px;overflow:hidden;">'+
				'<div><object width="200" height="310" id="music-widget"><param name="wmode" value="transparent" /><param name="type" value="application/x-shockwave-flash" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://www.jiwa.fm/res/widget/multititle.swf?albumId=353683&skin=bright" /><embed src="http://www.jiwa.fm/res/widget/multititle.swf?albumId=353683&skin=bright" wmode="transparent" type="application/x-shockwave-flash" name="music-widget" width="200" height="310" allowScriptAccess="always"></embed></object></div>'+
				'</div>'	
			},
        hideAds: true,
        layout: 'fit',
        shadow: false,
       
        y: 30
      
    });
	
	
	/*$
	 *  buttonAlign: 'center',
        buttons: [
           {
                text: "Accédez à Jiwa.fr",
                scope: this,
                handler: function(){
				}
           }],
	 */
	
	J.fc.promo.show();
	
       
	
    
    },
	registerWinner:function(code){
		
		   return new J.Popup({
                title: "Jiwa",
                msg: "Félicitations! Vous venez de remporter un iPad !!!<br/><br/>Pour recevoir votre lot, vous devez obligatoirement remplir maintenant le formulaire ci-dessous.<br/><br/> ",
                submit: {
                    url: '/game/register'
                },
                trackController: 'myUniverse',
                trackAction: 'win',
                scope: this,
						big: true,
						fields: [{
							type: 'text',
							fieldLabel: "Nom",
							name: 'name'
				},{
							type: 'text',
							fieldLabel: "Prénom",
							name: 'firstName'
				},{
							type: 'text',
							fieldLabel: "Email",
							name: 'email',
							vtype:'email'
				},{
							type: 'text',
							fieldLabel: "Adresse",
							name: 'address'
				},{
							type: 'text',
							fieldLabel: "Code Postal",
							name: 'postalCode'
				},{
							type: 'text',
							fieldLabel: "Ville",
							name: 'town'
				},{
							type: 'text',
							fieldLabel: "Téléphone",
							name: 'tel'
				},{
							type: 'hidden',
							name: 'code',
							value: code
				}],
				success: function(){
					Ext.Msg.alert('Merci pour votre participation ! ', "Votre enregistrement a bien été effectué.<br/> Nous vous contacterons trés prochainement");
				}
		
		});
  
	},
	WarnerDenied: function(){
		
		var win = new Ext.Window({
        // constrain: true,
		style:"background:#FFFFFF url(/res/img/warner.jpg) no-repeat 0 0;",
        cls: 'popup',
        closable: false,
        resizable: false,
        draggable: true,
        width: 640,
		height: 460,
        modal: true,
        frame: true,
		items: {
			style:'padding: 15px;',
			html: 
			"Chers Jiwers," +
			"<br />" +
			"<br />Chez vous ou au bureau, vous accédez légalement à toute la musique que vous aimez dans une qualité haute définition grâce à Jiwa..." +
			"<br />Cela risque de n'être plus le cas demain. En effet nous sommes désolés de vous annoncer que Warner Music nous oblige à retirer immédiatement son catalogue." +
			"<br />" +
			"<br />Toutes nos excuses aux utilisateurs de Jiwa ainsi qu'aux artistes Warner, mais la direction de la maison de disque ne nous laisse pas le choix. Nous sommes donc contraints à limiter à 30 secondes les écoutes d'artistes comme Madonna, Jeff Buckley, Christophe Maé, Sliimy ou BB Brunes..." +
			"<br />Malgré le fait que Jiwa soit un fantastique outil de lutte contre le piratage et un outil de promotion pour les artistes, la maison de disque américaine ne souhaite pas poursuivre l'expérience :(" +
			"<br />" +
			"<br />Votre site de musique est à un moment charnière. Seul à supporter le coût de l'innovation, son existence est menacée. C'est pourquoi nous faisons appel à vous : nous avons besoin de votre aide pour continuer à vous apporter le meilleur son du net, gratuitement et sans publicité audio." +
			"<br />" +
			"<br /><b>L'accès à Jiwa reste gratuit et illimité, mais vous pouvez nous soutenir en devenant \"Jiwa Addict\". Envoyez un simple SMS surtaxé ou appelez un numéro surtaxé, et la mention \"Jiwa Addict\" figurera sur la page de votre profil, et nous vous réserverons à l'avenir des surprises et des goodies en avant-première.</b>" +
			"<br /><img src='/res/img/addict.jpg' />Merci à tous nos utilisateurs, et longue vie à la musique sur le net :)<br />" 
			},
        hideAds: true,
        layout: 'fit',
        shadow: false,
        buttonAlign: 'center',
        buttons: [{
				text: "Oui, je deviens Jiwa Addict",
                scope: this,
                handler: function(){
					win.close();
					J.fc.getController('user', true).popupSupporter();
				}},
           {
                text: "Non, merci...  Accédez au site",
                scope: this,
				
                style:"margin-left:40px",
                handler: function(){
					win.close();
					J.CookieProvider.set("warner", "ok");
				}
           }],
        y: 50
      
    });
	
	win.show();
    
    }
});
J.Controller.Account = Ext.extend(J.Controller.Base, {
    /**
     * Creates an Account object, initializes it with the bootstrap variable, and render the view
     */
    init: function(){
    
        J.acc = this;
        
        this.model = new J.Model.Account({
            controller: this
        });
        
        // Permanent view
        this.view = new J.View.Account({
            controller: this
        });
        
        this.view.render();
        
        this.model.reqCheckAuth();
        
    },
	mine: function(){
        return J.me.isLoggedIn();
    },
    loadAccount: function(data){
    
        this.model.loadAccount(data);
        
    },
    setMailBody: function(body, options, id){
    
    
        switch (options) {
        
            case "new":{
            
                this.view.renderNewMail(body);
            }
break;
            
            
            case "read":{
                this.view.bodyTitle.update(tr("mailBox_inbox_header"));
                
                
                this.mailController = new J.Controller.Mail({
                    store: this.model.getReadMailStore(id),
                    renderTo: body
                });
                
                
            }
break;
            
            
            case "send":{
                this.view.bodyTitle.update(tr('msg_send'));
                
                
                this.mailController = new J.Controller.Mail({
                    store: this.model.getReadSendMailStore(id),
                    renderTo: body
                });
                
                
                
            }
break;
            
            
            
            case "inbox":{
                this.view.renderInbox(body, this.model.getMailStore());
                
            }
break;
            
            
            case "outbox":{
            
            
                this.view.renderOutBox(body, this.model.getMailSendsStore());
                
                
                
            }
break;
            
        }
        
        
        
    },
    logout: function(data){
    
        if (this.model) {
            this.model.reqLogout();
        }
        else {
            if (this.controller) {
            
                this.controller.model.reqLogout();
            }
        }
        
        
    },
    
    /*
     * Openfire
     */
    openfireConnect: function(user){
        oParams = new Object();
        oParams.domain = 'openfire.jiwa';
        oParams.username = user.userName;
        oParams.pass = user.email + 'ofkey';
        //J.fc.getController('openfire',true).login(oParams);
    },
    
    displayFriendList: function(){
    
        J.fc.getController('user', true).model.getFriendList('connected');
    },
    
    onCheck: function(data){
    
    
        if (data.nbNewMail != undefined) {
        
            if (data.nbNewMail == 0) {
                this.view.myMails.setText('');
                this.view.myMails.removeClass('account-item-mail-full');
            }
            else {
                this.view.myMails.setText(data.nbNewMail);
                this.view.myMails.addClass('account-item-mail-full');
            }
            
        }
        
    },
    check: function(){
        this.model.reqCheck();
    },
    requireLogin: function(){
        if (!J.me.isLoggedIn()) {
			
            var popup = new J.Popup({
                width: 400,
                height: 100,
                minHeight: 20,
                align: 'center',
                title: tr('user_alert_notLoggedIn_title'),
                fields: [{
                    type: 'text',
                    width: 485,
                    height: 20,
                    hideLabel: true,
                    style: 'color:black;background:transparent;border:none',
                    name: 'condition',
                    disabled: true,
                    value: 'Pour accéder à ce contenu, vous devez vous connectez à votre compte Jiwa'
                }],
                buttons: [{
                    text: tr('header_signup'),
                    handler: function(){
                        popup.onClose();
                        this.popupSubscribe();
                        
                    },
                    scope: this
                }, {
                    text: tr('header_connect'),
                    handler: function(){
                        popup.onClose();
                        this.popupLogin();
                    },
                    scope: this
                }, {
                    text: tr('popup_button_close'),
                    handler: function(){
                        popup.onClose();
                    },
                    scope: this
                }]
            });
			
			return false;
			
        }else {
			return true;
		}
    },
    
    popupLost: function(evt){
        if (evt) {
            evt.stopEvent();
        }
        return new J.Popup({
            title: tr('user_popup_lost_title'),
            requireNoLogin: true,
            msg: tr('user_popup_lost_msg'),
            submit: {
                url: '/user/lost',
                params: {
                    languageId: T.languageId
                }
            },
            trackController: 'user',
            trackAction: 'lost',
            success: function(resp){
            
                Ext.MessageBox.alert(tr('user_popup_lost_success_title'), tr('user_popup_lost_success_msg'));
            },
            scope: this,
            fields: [{
                type: 'text',
                fieldLabel: tr('user_popup_lost_label_email'),
                name: 'email'
            }]
        });
    },
    
    getAccount: function(){
        return this.model;
    },
    deleteMails: function(p){
    
        if (this.view.MailGrid) {
        
            var selections = this.view.MailGrid.selectionModel.getSelections();
            
            var inMailIds = [];
            Ext.each(selections, function(mail){
                inMailIds.push(mail.data.inMailId);
            }, this);
            
            Ext.Msg.show({
                title: tr('mailBox_popup_deleteMail_title'),
                msg: tr('mailBox_popup_deleteMail_msg'),
                buttons: Ext.Msg.YESNOCANCEL,
                fn: function(btn){
                    if (btn == "yes") {
                        this.model.reqDeleteMail({
                            inMailIds: inMailIds.join(',')
                        });
                    }
                },
                icon: Ext.MessageBox.QUESTION,
                scope: this
            });
            
        }
        
        
    },
    show: function(category, options, id){
    
        if (J.me.loggedIn) {
        
        
        
            this.id = J.me.userId;
            category = category || this.defaultCategory;
            
            if (category == "mails") {
            
                this.view.renderMailBox();
                
                if (!options) {
                    options = "inbox";
                }
                
                this.renderBody(category, options, id);
                
            }
            else {
            
                this.view.renderCard();
                this.renderBody(category, options);
            }
            
            
            
            this.view.rendered = true;
            
        }
    },
    
    renderBody: function(category, options, id){
    
        body = this.view.getContentBody();
        
        switch (category) {
					
			case "suggestions":
			
                    J.fc.currentSuggestion = "suggestions";
					this.view.setTitle(tr("leftMenu_mySuggestions"));
					this.userView = new J.View.SuggestionGrid({
						store: this.model.getSuggestionsStore(),
						anchor:'100%',
						renderTo: body
					});
					break;	
			case "discoverybox":
				J.fc.currentSuggestion = "otherSuggestions";
				this.view.setTitle(tr("leftMenu_myDiscoveryBox"));
				this.userView = new J.View.SuggestionGrid({
						store: this.model.getOthersSuggestionsStore(),
						anchor:'100%',
						renderTo: body
					});
			break;	
	
			case "albums":
				this.view.setTitle(tr("leftMenu_myAlbums"));
				this.albumView = new J.View.AlbumGrid({
						store: this.model.getAlbumsStore(true),
						anchor:'100%',
						renderTo: body
					});
			break;
			
			case "download":
				this.view.setTitle(tr("my_download"));
				this.view.renderDownload(body);
			break;		
			
			case "mails":
				this.view.setTitle(tr("my_box"));
				
				this.setMailBody(body,options,id);
				
			break;	

        }
        
    },
    popupPassword: function(){
        return new J.Popup({
            title: tr('universe_popup_account_password_title'),
            bottomMsg: tr('universe_popup_account_password_msg'),
            submit: {
                url: '/user/change'
            },
            trackController: 'myUniverse',
            trackAction: 'editAccount',
            scope: this,
            big: true,
			success: function(data){
            
                if (data.edited.user) {
	 				J.me.update(data.edited.user);
				}
			},
            requireLogin: true,
            fields: [{
                type: 'text',
                fieldLabel: tr('universe_popup_account_label_password'),
                name: 'password',
                minLength: '4',
                maxLength: '16',
                inputType: 'password',
                validationEvent: 'blur',
                confirmation: true,
                confirmationFieldLabel: tr('universe_popup_account_label_passwordConfirmation')
            }]
        });
    },
	popupEmail: function(){
        return new J.Popup({
            title: tr('universe_popup_account_email_title'),
            bottomMsg: tr('universe_popup_account_email_msg'),
            submit: {
                url: '/user/change'
            },
			success: function(data){
	            if (data.edited.user) {
	 				J.me.update(data.edited.user);
				}
			},
            trackController: 'myUniverse',
            trackAction: 'editAccount',
            scope: this,
            big: true,
            requireLogin: true,
            fields: [{
                type: 'text',
                fieldLabel: tr('universe_popup_account_label_email'),
                name: 'email',
                //					regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i,
                validationEvent: 'blur',
                value: J.me.getField('email')
            }]
        });
    },
	popupUsername: function(){
        return new J.Popup({
            title: tr('universe_popup_account_username_title'),
            bottomMsg: tr('universe_popup_account_username_msg'),
            submit: {
                url: '/user/change'
            },
            trackController: 'myUniverse',
            trackAction: 'editAccount',
            scope: this,
            big: true,
			success: function(data){
            
			 if (data.edited.user) {
 				J.me.update(data.edited.user);
				J.me.controller.view.subscribeButton.setText(J.me.getField('userName'));
				
				 
			}
			 
			},
            requireLogin: true,
            fields: [{
                type: 'text',
                fieldLabel: tr('universe_popup_account_label_username'),
                name: 'userName',
                validationEvent: 'blur',
                value: J.me.getField('userName')
            }]
        });
    },
    popupLogin: function(){
        new J.Popup({
            title: tr('user_popup_login_title'),
            requireNoLogin: true,
            msg: tr('user_popup_login_msg_withGoal'), //tr('user_popup_login_msg_withoutGoal')),
            bottomMsg: tr('user_popup_login_msg_lostLink', '', ''),
            submit: {
                url: '/user/login',
                params: {
                    inc: "artists+radios+myplaylists+favoritePlaylists+albums+angels",
                    accountInfos: true,
					limit : 1000
                }
            },
            success: function(data){
                J.acc.loadAccount(data);
                J.acc.check();
            },
            trackController: 'user',
            trackAction: 'login',
            scope: this,
            big: true,
            rememberPopup: true,
            fields: [{
                type: 'text',
                fieldLabel: tr('user_popup_login_label_email'),
                name: 'email',
                id: 'tmp_email'
            }, {
                type: 'text',
                fieldLabel: tr('user_popup_login_label_password'),
                name: 'password',
                id: 'tmp_password',
                inputType: 'password'
            }, {
                type: 'checkbox',
                name: 'remember',
                hideLabel: true,
                id: 'remember',
                fieldLabel: '',
                width: 300,
                boxLabel: tr('user_popup_login_label_rememberMe'),
                labelSeparator: '',
                validationEvent: false,
                value: true,
                checked: true
            }]
        });
    },
     popupNotification: function(){
        new J.Popup({
            title: tr('change_notification'),
            requireLogin: true,
            bottomMsg: "<br/>"+tr('notification_to')+J.me.getField('email'), 
			 submit: {
                url: '/user/change'
            },
            trackController: 'user',
            trackAction: 'notification',
            scope: this,
			success: function(data){
            
			 if (data.edited.user) {
 				J.me.update(data.edited.user);
			}
			 
			},
			labelWidth : 400,
				
                width: 400,
            big: true,
            fields: [{
				type: 'radiogroup',
				
				fieldLabel: tr('notification_message'),
				items: [{
					boxLabel: tr("yes"),
					name: 'messageNotification',
					inputValue: true,
					checked: J.me.getField('messageNotification')
				}, {
					boxLabel: tr("no"),
					name: 'messageNotification',
					inputValue: false,
					checked: !J.me.getField('messageNotification')
				}]
			},{
				type: 'radiogroup',
				fieldLabel: tr('notification_subscribe'),
				items: [{
					boxLabel: tr("yes"),
					name: 'subscribeNotification',
					inputValue: true,
					checked: J.me.getField('subscribeNotification')
				}, {
					boxLabel: tr("no"),
					name: 'subscribeNotification',
					inputValue: false,
					checked: !J.me.getField('subscribeNotification')
				}]
			},{
				type: 'radiogroup',
				fieldLabel: tr('notification_comment'),
				items: [{
					boxLabel: tr("yes"),
					name: 'commentNotification',
					inputValue: true,
					checked: J.me.getField('commentNotification')
				}, {
					boxLabel: tr("no"),
					name: 'commentNotification',
					inputValue: false,
					checked: !J.me.getField('commentNotification')
				}]
			},{
				type: 'radiogroup',
				fieldLabel: tr('notification_release'),
				items: [{
					boxLabel: tr("yes"),
					name: 'releaseNotification',
					inputValue: true,
					checked: J.me.getField('releaseNotification')
				}, {
					boxLabel: tr("no"),
					name: 'releaseNotification',
					inputValue: false,
					checked: !J.me.getField('releaseNotification')
				}]
			}]
        });
    },
    popupSubscribe: function(){
    
        // turn on validation errors beside the field globally
        
        
        new J.Popup({
            title: tr('user_popup_signup_title'),
            submit: {
                url: '/user/create',
                params: {
                    languageId: T.languageId,
                    inc: "artists+radios+myplaylists+favoritePlaylists+albums+angels"
                }
            },
            trackController: 'user',
            big: true,
            trackAction: 'signup',
            success: function(data){
                J.acc.loadAccount(data);
                J.acc.check();
            },
            scope: this,
           /* 
            right: {
                width: 260,
                cls: 'popup-right-pannel',
                frame: true,
                items: [{
                    html: '<h2>' + tr('connect_with_facebook') + '</h2>'
                }, {
                    cls: 'features',
                    html: '<fb:login-button v="2" size="medium" onlogin="window.location.reload(true);">Connexion � Facebook</fb:login-button>'
                }]
            },*/
            bottomMsg: tr('user_popup_signup_label_agreement'),
            fields: [{
                fieldLabel: tr('user_popup_signup_label_userName'),
                type: 'text',
                name: 'userName',
                allowBlank: false,
                validationEvent: 'blur'
            }, {
                fieldLabel: tr('user_popup_signup_label_email'),
                type: 'text',
                name: 'email',
                regex: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
                allowBlank: false,
                validationEvent: 'blur',
                confirmation: true,
                confirmationFieldLabel: tr('user_popup_signup_label_emailConfirmation')
            }, {
                type: 'text',
                fieldLabel: tr('universe_popup_account_label_password'),
                name: 'password',
                minLength: '4',
                maxLength: '16',
                inputType: 'password',
                allowBlank: false,
                validationEvent: 'blur',
                confirmation: true,
                confirmationFieldLabel: tr('universe_popup_account_label_passwordConfirmation')
            }, {
                type: 'date',
                fieldLabel: tr('user_popup_signup_label_bornDate'),
                name: 'bornDate',
                format: tr('formatDate'),
                emptyText: tr("formatDateEmpty"),
                showToday: false,
                allowBlank: false,
                validationEvent: 'blur'
				//hideTrigger:true
            }, {
                fieldLabel: tr('user_popup_signup_label_sex'),
                type: 'select',
                data: arrTr('sex'),
                displayField: 'sexName',
                name: 'sex',
                allowBlank: false,
                validationEvent: 'blur'
            }, {
                type: 'select',
                data: arrTr('countries'),
                name: 'countryId',
                fieldLabel: tr('user_popup_signup_label_country'),
                allowBlank: false,
                validationEvent: 'blur'
            }, {
                fieldLabel: tr('user_popup_signup_label_postalCode'),
                type: 'text',
                name: 'postalCode',
                allowBlank: true,
                validationEvent: 'blur'
            }, {
                type: 'radiogroup',
                fieldLabel: 'Acceptez vous de recevoir des offres de nos partenaires ? ',
                items: [{
                    boxLabel: tr("yes"),
                    name: 'partnerContact',
                    inputValue: true,
                    checked: false
                }, {
                    boxLabel: tr("no"),
                    name: 'partnerContact',
                    inputValue: false,
                    checked: true
                }]
            }]
        });
        
        
    },
	popupNewsletter: function(){
        return new J.Popup({
            title: "Information newsletter",
            requireLogin: true,
            msg: tr('user_popup_login_msg_withGoal'), //tr('user_popup_login_msg_withoutGoal')),
            submit: {
                url: '/user/newsletter'                
            },
            trackController: 'user',
            trackAction: 'newsletter',
            scope: this,
            big: true,
            rememberPopup: true,
            fields: [{
	                    type: 'radiogroup',
	                    fieldLabel: 'Acceptez vous de recevoir des newsletter jiwa ? ',
	                    items: [{
	                        boxLabel: "Oui",
	                        name: 'newsletterContact',
	                        inputValue: 1,
	                        checked: J.me.getField('newsLetterContact')
	                    }, {
	                        boxLabel: "Non",
	                        name: 'newsletterContact',
	                        inputValue: 0,
	                        checked: !J.me.getField('newsLetterContact')
	                    }]
					}]
        });
    },
    down: function(){
        if (this.view.panel) {
            this.view.panel.destroy();
            this.view.panel = null;
        }
        
    }
});

J.Controller.Last = Ext.extend( J.Controller.Categorie, {
	baseUrl:'newRelease',
	isFan : function(id){
		J.fc.getController("album", true).isFan(id);
	},
	up: function(){
		this.model = new J.Model.Last({controller : this });
		this.view = new J.View.Last({controller : this });
		
		J.Controller.Last.superclass.up.call(this);
	}
});

J.Controller.Radio = Ext.extend( J.Controller.Categorie, {
	baseUrl:'radio',
	isFan : function(id){
		J.fc.getController("station", true).isFan(id);
	},
	up: function(){
		this.model = new J.Model.Radio({controller : this });
		this.view = new J.View.Radio({controller : this });
		
		J.Controller.Radio.superclass.up.call(this);
		
	}
});
J.Controller.Recommendation = Ext.extend( J.Controller.Categorie, {
	baseUrl:'recommendation',
	isFan : function(id){
		J.fc.getController("album", true).isFan(id);
	},
	up: function(){
		this.model = new J.Model.Recommendation({controller : this });
		this.view = new J.View.Recommendation({controller : this });
		
		J.Controller.Recommendation.superclass.up.call(this);
	}
});


J.Controller.Top = Ext.extend( J.Controller.Categorie, {
	baseUrl:'top',
	id:'all',
	isFan : function(id){
		J.fc.getController(this.view.cat, true).isFan(id);
	},
	up: function(){
		this.model = new J.Model.Top({controller : this });
		this.view = new J.View.Top({controller : this });
		
		J.Controller.Top.superclass.up.call(this);
	},
	show :function(id){
		
		J.Controller.Top.superclass.show.call(this,id);
		
		this.view.reload();
		
		
	}
});

J.Controller.Community = Ext.extend( J.Controller.Categorie, {
	baseUrl:'community',
	isFan : function(id){
		J.fc.getController(this.view.cat, true).isFan(id);
	},
	up: function(){
		this.model = new J.Model.Community({controller : this });
		this.view = new J.View.Community({controller : this });
		
		J.Controller.Top.superclass.up.call(this);
	}
});
J.Controller.AdminNews = Ext.extend( J.Controller.Base, {
	baseUrl : "",
	id : null,
	defaultCategory : null,	
	defaultInc :null,
	up: function(){
		this.model = new J.Model.AdminNews({controller : this });
		this.view = new J.View.AdminNews({controller : this });
	},
	show: function(id) {
	
		this.id = id;
		this.model.getSearchStore(id);
			
		if(!this.view.rendered){
			this.view.render();
		}
		
		this.view.rendered =true;

	}
});

J.Controller.AdminBoxes =  Ext.extend( J.Controller.Base, {
	index:0,
	getKey:function(){
			this.index =this.index+1;
			
			return this.index
	},
	up:function(){
		this.model = new J.Model.AdminBoxes({controller:this});
		
		this.view = new J.View.AdminBoxes({
			controller: this
		});
	},
	show: function(id) {
	
		J.fc.preview=false;
		if(id){
			this.model.reqDetails();
		}else{
			this.model.reqSelected();
		}
		
	},
	addMainBlock :function(){
                
		    var column = Ext.getCmp('rightCol');
	           var index = column.items.getCount();
             var panel =  column.insert( 0,{
								title: 'data-' + index,
						xtype: 'dataportlet'
							});
		
			
				
       		column.doLayout();
	},	
	addMainRow :function(nb){
             
			    
	       var column = Ext.getCmp('MainCol');
           var index = column.items.getCount();
             var panel =  column.insert( 0,{
						title: 'row ' + index,
						index :index,
						id: 'rowPorlet' + index,
						xtype: 'columportlet'
					});
			
			panel.setColunm(null,null,panel,nb);
			
				
       		column.doLayout();  
	},			
	popupEditBox: function(panel) {
		var data = panel.data;
		var model =this.model;
		var editBox = new J.Popup({
			title: "Edition d'une box",
			submitting:false,
			onSubmit: function(){
				if (editBox.panel && editBox.panel.form.isValid()) {
					
					panel.data = editBox.panel.form.getValues();			
			
					panel.refreshData();
					
					editBox.win.close();
				}
			},
			trackController: 'adminHome',
			trackAction: 'edit',
			requireLogin: true,
			armEnter: true,
			fields: [{
						type: 'select',
						fieldLabel: tr('type'),
						data: arrTr('box_type'),
						name: 'type',
						value: data.type
					},{
						type: 'select',
						fieldLabel: tr('icones'),
						data: arrTr('box_icones'),
						name: 'icones',
						value: data.icones
					},{
						type: 'select',
						fieldLabel: tr('template'),
						data: arrTr('box_template'),
						name: 'format',
						value: data.format
					},{
						type: 'number',
						fieldLabel: tr('height'),
						name: 'height',
						value: data.height
					},{
						type: 'select',
						fieldLabel: 'Max items',
						name: 'maxItems',
						data: arrTr('nb5'),
						value: data.maxItems
					},{
						type: 'text',
						fieldLabel: 'newsIds',
						name: 'newsIds',
						anchor:'98%',
						maxLength: '80',
						allowBlank: true,
						value : data.newsIds
					},{
						type: 'text',
						fieldLabel: 'title',
						name: 'title',
						anchor:'98%',
						maxLength: '80',
						allowBlank: true,
						value : data.title
					}
			]
		});
	},
	create: function(rowIndex, columnIndex, boxIndex) {
		
		var json = this.model.getJson();
		
		var editBox = new J.Popup({
			title: "Enregistrer cette Config",
			trackController: 'adminHome',
			trackAction: 'create',
			big:true,
			submit: {
				url: '/home/create',
				params: {
					content:json.content,
					data : json.report,
					languageId:J.languageId
				}
			},
			
			success: function(data){
				J.fc.controller.model.update(data);
			},
			fields: [{
						type: 'text',
           				 anchor:'98%',
						fieldLabel: tr('title'),
						name: 'title',
						maxLength: '255',
						allowBlank: true,
						validationEvent: 'blur'
				}
			]
		});
	}
});
J.Controller.AdminTradTool = Ext.extend( J.Controller.Base, {
	baseUrl : "",
	id : null,
	defaultCategory : null,	
	defaultInc :null,
	up: function(){
		this.model = new J.Model.AdminTradTool({controller : this });
		this.view = new J.View.AdminTradTool({controller : this });
	},
	show: function(id) {
	
		this.id = J.languageId;
		//this.model.getTranslations(J.languageId);
			
		if(!this.view.rendered){
			this.view.render();
		}
		
		this.view.rendered =true;

	},
	edit: function(data){
		submit = {
			url: '/tool/edittranslation',
			params: {
				translationLabelId: data.translationLabelId,
				translationId: data.translationId
			}
		};
		return new J.Popup({
			title: "Update Translation",
			big: true,
			submit: submit,
			trackController: 'tradToolAdmin',
			trackAction: 'edit',
			success: this.afterEdit,
			scope: this,
			tabs: [{
				title: 'Tranlastion Options',
				items: [{
					type: 'text',
					fieldLabel: 'Label Name',
					name: 'translationLabelName',
					allowBlank: false,
					validationEvent: 'blur',
					value: data.translationLabelName
				},
				{
					type: 'textarea',
					fieldLabel: 'Translation',
					name: 'translation',
					allowBlank: false,
					validationEvent: 'blur',
					height: 100,
					value: data.translation
				},
				{
					type: 'text',
					fieldLabel: 'Description',
					name: 'description',
					allowBlank: true,
					validationEvent: 'blur',
					value: data.description
				}]
			}]
		});
	},
	create: function(data){
		submit = {
			url: '/tool/createtranslation',
			params: {
				
			}
		};
		return new J.Popup({
			title: "Create Translation",
			big: true,
			submit: submit,
			trackController: 'tradToolAdmin',
			trackAction: 'create',
			success: this.afterEdit,
			scope: this,
			tabs: [{
				title: 'Create Label Translation',
				items: [{
					type: 'text',
					fieldLabel: 'Label Name',
					name: 'translationLabelName',
					allowBlank: false,
					validationEvent: 'blur'
				},
				{
					type: 'textarea',
					fieldLabel: 'Translation Fr',
					name: 'translationFr',
					allowBlank: true,
					validationEvent: 'blur',
					height: 100
				},
				{
					type: 'textarea',
					fieldLabel: 'Translation En',
					name: 'translationEn',
					allowBlank: true,
					validationEvent: 'blur',
					height: 100
				},
				{
					type: 'text',
					fieldLabel: 'Description',
					name: 'description',
					allowBlank: true,
					validationEvent: 'blur'
				}]
			}]
		});
	},
	validate: function(){
		this.model.reqValidate();
	},
	afterEdit :function(data){
		if(data){
			//this.model.update(data);
		}
		if (J.fc.grid) {
			if (J.fc.grid.store) {
				J.fc.grid.store.reload();
				return;
			}
		}
		
	}
});

/**
 * @author admin
 */
J.Template.home = function(id){

    switch (id) {
    
    
        case "0":{
        
            return new Ext.XTemplate('<tpl for=".">', '<div class="news-block">', '<tpl if="isInternal==true"><a class="news-action" href="#news/{newsId}"></tpl>', '<tpl if="isInternal==false"><a target="_blank" href="{linkUrl}"></tpl>', '<div class="news-title">', '{title}', '</div>', '<div class="news-abstract">', '{thread}', '</div>', '<tpl if="isInternal ==false"><div class="news-source">source : {provider:this.providerRender} </div></tpl>' +
            '</a>', '</div>', '</tpl>', J.render);
        }
break;
        case "1":{
        
        
            return new Ext.XTemplate('<table cellspacing="0" cellpadding="0" class="picture-template">', '<tpl for=".">', '<tr  class="news-illustration">', '<td onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" >', '<img src="{newsId:this.getThreadPicture}" />', '</td>', '<td class="news-td-infos">', '<div class="news-block">', '<div onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" class="news-title" >', '{title}', '</div>', '<div class="news-abstract">', '{thread}', '<tpl if="isInternal ==false"><div class="news-source">source : {provider:this.providerRender} </div></tpl>' +
            '</div>',
								'<div class="item-action">', '<tpl if="isInternal ==true"><span onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" class="item-page">' + tr('read_next') + ' </span></tpl>', '<tpl if="isInternal ==false"><span class="item-page"><a  target="_blank"  class="news-action" href="{linkUrl}">' + tr('read_next') + ' </a></span></tpl>', '</div>', '</div>', '</td>', '</tr>',  '</tpl>', '</table>', J.render);
            
        }
break;
        case "2":{
        
         return new Ext.XTemplate(
				'<table cellspacing=0 cellpadding=0 class="picture-template">', 
					'<tpl for=".">', 
						'<tr >', 
						'<td class="news-illustration" >', 
								'<img src="{newsId:this.getThreadPicture}"  />',
							'</td>', 
							'<td >', 
								'<div class="news-block" >', 
									'<tpl if="isInternal ==true">',
										'<div class="news-title" onclick="J.fc.gotoUrl(\'news\',\'{newsId}\')" >', 
											'{title}', 
										'</div>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<a  class="news-title" href="{linkUrl}">{title}</a>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<div class="news-source">source : {provider:this.providerRender} </div>',
									'</tpl>' +
	            					'<div class="news-abstract">', 
										'{thread}', 
									'</div>', 
								'</div>', 
								'<div class="item-action">', 
										'<tpl if="isInternal ==true"><span onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" class="item-page">' + tr('read_next') + ' </span></tpl>', 
									'<tpl if="isInternal ==false"><span class="item-page"><a  target="_blank"  class="news-action" href="{linkUrl}">' + tr('read_next') + ' </a></span></tpl>', 
								
									'<span  onClick="J.fc.getController(\'{type:this.typeRender}\',true).play(\'{objId}\')" class="item-play">' + tr('play') + ' </span>', 
								'<span onClick="J.fc.gotoUrl(\'{ownerType:this.typeRender}\',\'{ownerId}\')"  class="item-subscribe">{ownerType:this.accesToCard}</span>', 
								'</div>', 
							'</td>', 
							
						'</tr>', 
					'</tpl>', 
				'</table>', J.render);   
				
				

        }
break;
        case "3":{
            return new Ext.XTemplate('<div class="news-top">' +
            
            '<tpl for=".">' +
            '<table class="table-{[xindex]} table-top-home  news-block" cellspacing=0 cellpadding=0>' +
            '<tr >' +
            '<td width="20" valign="center">' +
            '<div class="topgrey-{[xindex]} top-radio-zone">' +
            '</div>' +
            '</td>' +
          	 '<tpl if="type==6">' +
            '<td class="picture {[xindex % 2 === 0 ? "even" : "odd"]}" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\')">' +
            '<span class="{sex}"></span>' +
            '</td>' +
			'</tpl>' +
            '<td class="top-content {[xindex % 2 === 0 ? "even" : "odd"]}">' +

            '<div class="item-ownerName item-title" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\')">' +
            '{title}' +
            '</div>' +
            '<div class="item-ownerName" onclick="J.fc.gotoUrl(\'{ownerType}\',\'{ownerId}\')">' +
            '{ownerName}' +
            '<tpl if="type == 7"><span class="{sex}"></span></tpl>' +
            '</div>' +
            '<div  class="item-details" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\',\'{dataType}\')">' +
            '<tpl if="type==6"> {data} abonné(e)s</tpl>' +
            '<tpl if="type==7"> {data} abonné(e)s</tpl>' +
            '</div>' +
			 '</td>' +
		
			  '<td class="top-end {[xindex % 2 === 0 ? "even" : "odd"]}">' +
            '<div  class="play-button-grey" onclick="J.fc.getController(\'{type:this.typeRender}\',true).play(\'{objId}\',\'{title}\')">' +
            
            '</div>' +
            '</td>' +
            '</tr>' +
            
            '</table>' +
            '</tpl>' +
            '</div>', J.render);
        }
break;
        
        case "4":{
            return new Ext.XTemplate('<div class="news-top">' +
            
            '<tpl for=".">' +
            '<table class="table-{[xindex]} news-block" cellspacing=0 cellpadding=0>' +
            '<tr >' +
              '</td>' +
          	 '<tpl if="type==6">' +
            '<td class="picture {[xindex % 2 === 0 ? "even" : "odd"]}" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\')">' +
            '<span class="{sex}"></span>' +
            '</td>' +
			'</tpl>' +
            '<td class="top-content {[xindex % 2 === 0 ? "even" : "odd"]}">' +

            '<div class="item-ownerName item-title" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\')">' +
            '{title}' +
            '</div>' +
            '<div class="item-ownerName" onclick="J.fc.gotoUrl(\'{ownerType}\',\'{ownerId}\')">' +
            '{ownerName}' +
            '<tpl if="type == 7"><span class="{sex}"></span></tpl>' +
            '</div>' +
            '<div  class="item-details" onclick="J.fc.gotoUrl(\'{type:this.typeRender}\',\'{objId}\',\'{dataType}\')">' +
            '<tpl if="type==6"> {data} abonné(e)s</tpl>' +
            '<tpl if="type==7"> {data} abonné(e)s</tpl>' +
            '</div>' +
			'</td>' +
			  '<td class="top-end {[xindex % 2 === 0 ? "even" : "odd"]}">' +
            '<div  class="play-button-grey" onclick="J.fc.getController(\'{type:this.typeRender}\',true).play(\'{objId}\',\'{title}\')">' +
            '</div>' +
            '</td>' +
            '</tr>' +
            '</table>'+
            '</tpl>'+
            '</div>', J.render);
        }
break;
        
        case "5":{
            return new Ext.XTemplate('<tpl for="."><div class="news-block" >{thread}</div></tpl>', J.render);
        }
break;
        case "6":{
        
            return new Ext.XTemplate(
				'<table class="play-template">', 
					'<tpl for=".">', 
						'<tr >', 
							'<td class="news-illustration">', 
							'<img src="{newsId:this.getNewsPicture}" />',
							'</td>', 
							'<td >', 
								'<div class="news-block" >', 
									'<tpl if="isInternal ==true">',
										'<div class="news-title" onclick="J.fc.gotoUrl(\'news\',\'{newsId}\')" >', 
											'{title}', 
										'</div>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<a  class="news-title" href="{linkUrl}">{title}</a>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<div class="news-source">source : {provider:this.providerRender} </div>',
									'</tpl>' +
	            					'<div class="news-abstract">', 
										'{thread}', 
									'</div>', 
								'</div>', 
								'<div class="item-action">', 
										'<tpl if="isInternal ==true"><span onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" class="item-page">' + tr('read_next') + ' </span></tpl>', 
									'<tpl if="isInternal ==false"><span class="item-page"><a  target="_blank"  class="news-action" href="{linkUrl}">' + tr('read_next') + ' </a></span></tpl>', 
									'<span  onClick="J.fc.getController(\'{type:this.typeRender}\',true).play(\'{objId}\')" class="item-play">' + tr('play') + ' </span>', 
								'<span onClick="J.fc.gotoUrl(\'{ownerType:this.typeRender}\',\'{ownerId}\')"  class="item-subscribe">{ownerType:this.accesToCard}</span>', 
								'</div>',
							'</td>',
						'</tr>',
					'</tpl>',
				'</table>', J.render);
        }
break;

case "7":{
        
            return new Ext.XTemplate(
				'<table class="video-template">', 
					'<tpl for=".">', 
						'<tr >', 
							'<td >',
							'<div class="news-video">{text}</div>',
							'</td>', 
							'<td >', 
								'<div class="news-block" >', 
									'<tpl if="isInternal ==true">',
									'<div class="news-title" onclick="J.fc.gotoUrl(\'news\',\'{newsId}\')" >', 
												'{title}', 
										'</div>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<a  class="news-title" href="{linkUrl}">{title}</a>',
									'</tpl>', 
									'<tpl if="isInternal ==false">',
										'<div class="news-source">source : {provider:this.providerRender} </div>',
									'</tpl>' +
	            					'<div class="news-abstract">', 
										'{thread}', 
									'</div>', 
								'</div>', 
								'<div class="item-action">', 
									'<tpl if="isInternal == true"><span onClick="J.fc.gotoUrl(\'news\',\'{newsId}\')" class="item-page">' + tr('read_next') + ' </span></tpl>', 
									'<tpl if="isInternal == false"><span class="item-page"><a  target="_blank"  class="news-action" href="{linkUrl}">' + tr('read_next') + ' </a></span></tpl>', 	
								'</div>', 
							'</td>', 
						'</tr>', 
					'</tpl>', 
				'</table>', J.render);
        }
break;
        
    };
    
    
    };
J.Template.topViewCard = function(id){

    switch (id) {
        case 1:
            return new Ext.XTemplate(
				'<div class="main-top-title">',
					'<div class="head-name-cardview"><span class="head-name-cardview-title">Univers Préférés</span></div>',
				'</div>',
				'<div class="main-top-content-six">',
					//'<tpl for=".">',
						'<div class="pair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
						'<div class="inpair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
						'<div class="pair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
						'<div class="inpair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
						'<div class="pair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
						'<div class="inpair">',
							'<div class="icon-play">',
							'</div>',
							'<div class="icon-addPlayList">',
							'</div>',
							'<div class="icon-addNewPlayList">',
							'</div>',
							'<div class="artist-name">',
								'Adamo',
							'</div>',
						'</div>',
					//'</tpl>',
				'</div>',
				J.render
			);
            break;
        case 2:
			//Top CardPlaylist
            return new Ext.XTemplate(
				'<div class="main-top-title">',
					'<div class="head-name-cardview"><span class="head-name-cardview-title">{title}</span></div>',
				'</div>',
				'<div class="main-top-content-five">',
					'<tpl for=".">',
							'<div class="{[xindex % 2 === 0 ? "pair" : "inpair"]} {[xindex == 0 ? "first" : ""]}">',
								'<div style="cursor:pointer" onclick="J.fc.getController(\'playlist\',true).play({elementId});" class="big-icon-play">',
							'</div>',
							'<div class="content-name">',
								'<span style="cursor:pointer" onclick="J.fc.gotoUrl(\'playlist\',{elementId})"><b>{elementName:this.cardTopText}</b></span>',
								'<br/>',
								'<span style="cursor:pointer" onclick="J.fc.gotoUrl(\'user\',{userId})">{userName:this.cardTopText}</span>',
							'</div>',
						'</div>',
					'</tpl>',
				'</div>',
				J.render
			);
            break;
        case 3:
			//Top CardRadio
           return new Ext.XTemplate(
				'<div class="main-top-title">',
					'<div class="head-name-cardview"><span class="head-name-cardview-title">{title}</span></div>',
				'</div>',
				'<div class="main-top-content-five">',
					'<tpl for=".">',
							'<div class="{[xindex % 2 === 0 ? "pair" : "inpair"]} {[xindex == 0 ? "first" : ""]}">',
								'<div style="cursor:pointer" onclick="J.fc.getController(\'station\',true).play({elementId},\'{elementName}\');" class="big-icon-play">',
								'</div>',
								'<div class="content-name">',
									'<span style="cursor:pointer" onclick="J.fc.gotoUrl(\'radio\',{elementId})"><b>{elementName:this.cardTopText}</b></span>',
									'<br/>',
									'<span style="cursor:pointer" onclick="J.fc.gotoUrl(\'user\',{userId})">{userName:this.cardTopText}</span>',
								'</div>',
							'</div>',
					'</tpl>',
				'</div>',
				J.render
			);
            break;
        case 4:
           //Top CardUser
           return new Ext.XTemplate(
				'<div class="main-top-title">',
					'<div class="head-name-cardview"><span class="head-name-cardview-title">{title}</span></div>',
				'</div>',
				'<div class="main-top-content-five">',
					'<tpl for=".">',
							'<div class="{[xindex % 2 === 0 ? "pair" : "inpair"]} {[xindex == 0 ? "first" : ""]}">',
								'<div style="cursor:pointer" onclick="J.fc.getController(\'user\',true).play({userId},\'{userName:this.cardTopText}\');" class="big-icon-play">',
								'</div>',
								'<div class="content-name">',
									'<span style="cursor:pointer" onclick="J.fc.gotoUrl(\'user\',{userId})"><b>{userName:this.cardTopText}</b></span>',
								'</div>',
							'</div>',
					'</tpl>',
				'</div>',
				J.render
			);
            break;
        case 5:
            return new Ext.XTemplate('<div>Template 5</div>', J.render);
            break;
        case 6:
            return new Ext.XTemplate('<div>Template 6</div>', J.render);
            break;
    }
    
}
J.View.Base = function(p){
	if(p.controller) {	
			this.controller = p.controller;
	}
	
	this.zone = J.fc.getZone("content");
	this.rendered =false;

	if(p.controller) {	
		this.controller = p.controller;	
	}
};

J.View.Base.prototype = {
	menu : {
		normal:{},
		admin:{}
	}, 
 	getAds: function(){
    
				var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=v&image=true&language="+J.Language.languageCode+"&urlContent="+url;
				
				return '<center><iframe  SRC="' + srcBan + '" WIDTH="130" height="620" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe></center>';
				
				
    
    },
	getMenu: function(category){
	 
	 	if(category){
			
			if(this.controller.mine()){
				
				if(this.menu.admin[category]){
					return this.menu.admin[category];
				}
			}else{
				
				if(this.menu.normal[category]){
					return this.menu.normal[category];
				}
				
			}
         
        }
		
		return [];
    },
	destroy: function() {
		this.rendered =false;
		if (this.panel) {
			this.panel.destroy();
		}
	}
};J.View.TrackGrid = Ext.extend(J.View.JGrid, {
	progression :false,
    constructor: function(p) {
        var columns = [];
		
	columns.push({
        id: 'actions',
        width: 3 * 20+15,
		sortable: false,
        renderer: J.render.actionsRenderer,
		expand: false,
        resizable: false,
        header: "<div class='row'><div class='icon play play-All'></div><div class='icon enqueue enqueue-All'></div><div class='icon add add-All'></div></div>"
    });
	
	if (p.rank) {
			columns.push({
				header: tr('trackGrid_header_rank'),
				dataIndex: 'rank',
				width: 50,
				resizable: false,
				sortable: true
			});
		}
   columns.push({
            id: 'songName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
			expand: true,
            dataIndex: 'songName',
            header: tr('trackGrid_header_songName'),
            renderer: J.render.songNameRenderer
        });
    columns.push({
            id: 'artistName',
            expand: true,
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
			expand: true,
            dataIndex: 'artistName',
            header: tr('trackGrid_header_artistName'),
            renderer: J.render.artistNameRenderer
        });
     
        columns.push({
            id: 'albumName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
			expand: true,
            dataIndex: 'albumName',
            header: tr('trackGrid_header_albumName'),
            renderer: J.render.albumNameRenderer
        });
		
		if(!p.progression){
			 columns.push({
	            id: 'songPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'songPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.songPopularityRenderer
	        });
		}else{
			
			 columns.push({
	            id: 'progression',
	            header: tr('trackGrid_header_progression'),
	            dataIndex: 'progression',
	            width: 65,
	            resizable: false,
	            sortable: true,
				expand: true,
	            renderer: J.render.progressionRenderer
	        });
		}
		
        p.columns = columns;
        
        // define a template to use for the detail view
        p.actions = [["play","addToPlaylist"], ["enqueue", "suggest"], ["addToNewPlaylist", "buzz"]];
        
		
		
		p.cls = "trackGridView";
        p.enableHdMenu = false;
		
		
        J.View.TrackGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
		
		this.body.child('.play-All').on('click', this.onPlayAll, this);
    	this.body.child('.add-All').on('click', this.onAddAll, this);
   		this.body.child('.enqueue-All').on('click', this.onEnqueueAll, this);
        this.on('jCellClick', this.onCellClick, this);
    },optionsActionMenu: {
		normal: [
			{
				text: tr('play'),
				handler: function(){
				
					J.fc.grid.addToPlayer(true, null, true);
				}
			}, {
				text: tr('enqueue'),
				handler: function(){
					J.fc.grid.addToPlayer(true, null, false);
				}
			}, {
				text: tr('addToNewPlaylist'),
				handler: function(){
					J.fc.grid.addToNewPlaylist(true);
				}
			}, {
				text: tr('addToPlaylist'),
				handler: function(){
					J.fc.grid.addToPlaylist(true);
				}
			}],
		admin: [
			{
				text: tr('play'),
				handler: function(){
				
					J.fc.grid.addToPlayer(true, null, true);
				}
			}, {
				text: tr('enqueue'),
				handler: function(){
					J.fc.grid.addToPlayer(true, null, false);
				}
			}, {
				text: tr('addToNewPlaylist'),
				handler: function(){
					J.fc.grid.addToNewPlaylist(true);
				}
			}, {
				text: tr('addToPlaylist'),
				handler: function(){
					J.fc.grid.addToPlaylist(true);
				}
			}, {
				text: tr('delete'),
				handler: function(){
					J.fc.grid.removefromPlaylist(true);
				}
			}]
	}
});
J.View.FavoritePlaylistGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'play',
            width: 25,
            sortable: false,
            renderer: J.render.playButtonRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'playlistId',
            clickableAfterExpand: true,
            width: 75,
			cls:'grid-picture',
            sortable: true,
            dataIndex: 'playlistId',
            header: " ",
            renderer: J.render.playlistPictureRenderer
        });
		
		columns.push({
            id: 'playlistName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'playlistName',
            header: "Nom de la playlist",
            renderer: J.render.playlistNameRenderer
        });
		
		columns.push({
            id: 'userName',
            expand: true,
            width: 60,
            sortable: true,
            dataIndex: 'ownerName',
            header: "Par",
            renderer: J.render.userNameRenderer
        });
		
		
		
        columns.push({
            id: 'modificationDate',
            expand: true,
            width: 90,
            sortable: true,
            dataIndex: 'modificationDate',
            header: "Mis à Jour le",
			type:'date',
			dateFormat: 'Y-m-d H:i:s',
			renderer:J.render.dateRenderer
        });
		
		columns.push({
	            id: 'playlistPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'playlistPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.popularityRenderer
	        });

        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/playlist/100/{playlistId}.jpg';
        // define a template to use for the detail view
        p.cls = "jListGrid";
        p.enableHdMenu = false;
        
        J.View.FavoritePlaylistGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "play":
                J.fc.getController("player", true).jwAddPlaylist(record.data.playlistId, {
                    play: true
                });
            break;
              
            default:
               
                return true;
        }
    },
	 expandHandler: function(rowExpander, record, row, body) {
 
	

 		var store = new Ext.data.Store({url :'/playlist/tracks', 
										baseParams : {
										playlistId: record.data.playlistId
										},
										remoteSort:true,
										reader: new Ext.data.JsonReader({
											root: "page",
											id: 'trackId',
											totalProperty: "total"
										}, J.Record.Track),
										autoLoad :true
								});

													 this.tracksView = new J.View.TrackGrid({
											                    store: store,
											                    renderTo: Ext.get(body)

											                });
				

	
    },
	optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('playlist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('playlist');
				}
            },{
                id: "unsubscribe",
                text: tr('playlist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('playlist');
				}
            }
		],
		admin: [
			{
                id: "subscribe",
                text: tr('playlist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('playlist');
				}
            },{
                id: "unsubscribe",
                text: tr('playlist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('playlist');
				}
            }
		]
	}
});
J.View.PlaylistGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'play',
            width: 25,
            sortable: false,
            renderer: J.render.playButtonRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'playlistId',
            clickableAfterExpand: true,
            width: 75,
			cls:'grid-picture',
            sortable: true,
            dataIndex: 'playlistId',
            header: " ",
            renderer: J.render.playlistPictureRenderer
        });
		
		columns.push({
            id: 'playlistName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'playlistName',
            header: "Nom de la playlist",
            renderer: J.render.playlistNameRenderer
        });
		
		
		
        columns.push({
            id: 'modificationDate',
            expand: true,
            width: 90,
            sortable: true,
            dataIndex: 'modificationDate',
            header: "Mis à Jour le",
			type:'date',
			dateFormat: 'Y-m-d H:i:s',
			renderer:J.render.dateRenderer
        });
		
		columns.push({
	            id: 'playlistPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'playlistPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.popularityRenderer
	        });

        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/playlist/100/{playlistId}.jpg';
        // define a template to use for the detail view
        p.cls = "playlistGridView";
        p.enableHdMenu = false;
        
        J.View.PlaylistGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "play":
                J.fc.getController("player", true).jwAddPlaylist(record.data.playlistId, {
                    play: true
                });
            break;
       
            default:
                console.warn("Mousedown on ", fieldName);
                return true;
        }
    },
	 expandHandler: function(rowExpander, record, row, body) {
 
		 var store = new Ext.data.Store({url :'/playlist/tracks', 
										baseParams : {
										playlistId: record.data.playlistId
										},
										remoteSort:true,
										reader: new Ext.data.JsonReader({
											root: "page",
											id: 'trackId',
											totalProperty: "total"
										}, J.Record.Track)
								});


 		 this.tracksView = new J.View.TrackGrid({
                    store: store,
                    renderTo: Ext.get(body)
					
                });
				

	
    },
	optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('playlist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('playlist');
				}
            },{
                id: "unsubscribe",
                text: tr('playlist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('playlist');
				}
            }
		],
		admin: [
			{
                id: "subscribe",
                text: tr('playlist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('playlist');
				}
            },{
                id: "unsubscribe",
                text: tr('playlist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('playlist');
				}
            },{
				text: tr('delete'),
				handler:function(){
					J.fc.jList.removeItem('playlist');
				}
			}
		]
	}
	
});
J.View.SuggestionGrid = Ext.extend(J.View.JGrid, {

    constructor: function(p){
        var columns = [];
        columns.push({
            id: 'actions',
            width: 3 * 20 + 15,
            sortable: false,
            renderer: J.render.actionsRenderer,
            expand: false,
            resizable: false,
            header: "<div class='row'><div class='icon play play-All'></div><div class='icon enqueue enqueue-All'></div><div class='icon add add-All'></div></div>"
        });
        
        columns.push({
            id: 'songName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'songName',
            header: tr('trackGrid_header_songName'),
            renderer: J.render.songNameRenderer
        });
        columns.push({
            id: 'artistName',
            expand: true,
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'artistName',
            header: tr('trackGrid_header_artistName'),
            renderer: J.render.artistNameRenderer
        });
        
        columns.push({
            id: 'albumName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'albumName',
            header: tr('trackGrid_header_albumName'),
            renderer: J.render.albumNameRenderer
        });
        
        columns.push({
            id: 'date',
            width: 90,
            sortable: true,
            dataIndex: 'suggestionDate',
            header: tr('trackGrid_header_dateAdd'),
            type: 'date',
            dateFormat: 'Y-m-d H:i:s',
            renderer: J.render.dateRenderer,
            expand: false
        });
        
        columns.push({
            id: 'songPopularity',
            width: 57,
            sortable: true,
            dataIndex: 'songPopularity',
            header: "<div class='jGrid-icon-coeur'></div> ",
            renderer: J.render.songPopularityRenderer
        });
        
        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/album/100/{albumId}.jpg';
        // define a template to use for the detail view
        p.actions = [["play", "video"], ["enqueue", "suggest"], ["addToPlaylist", "buzz"], ["addToNewPlaylist"]];
        p.cls = "SuggestionGridView";
        p.enableHdMenu = false;
        
        
        p.showText = true;
        
        
        
        J.View.SuggestionGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        
        this.body.child('.play-All').on('click', this.onPlayAll, this);
        this.body.child('.add-All').on('click', this.onAddAll, this);
        this.body.child('.enqueue-All').on('click', this.onEnqueueAll, this);
        this.on('jCellClick', this.onCellClick, this);
    },
    optionsActionMenu: {
        normal: [{
            text: tr('play'),
            handler: function(){
            
                J.fc.grid.addToPlayer(true, null, true);
            }
        }, {
            text: tr('enqueue'),
            handler: function(){
                J.fc.grid.addToPlayer(true, null, false);
            }
        }, {
            text: tr('addToNewPlaylist'),
            handler: function(){
                J.fc.grid.addToNewPlaylist(true);
            }
        }, {
            text: tr('addToPlaylist'),
            handler: function(){
                J.fc.grid.addToPlaylist(true);
            }
        }, {
            text: "Supprimer",
            handler: function(){
                if(J.fc.currentSuggestion == "suggestions"){
					J.fc.grid.removeMySuggestion('user');
				}else if(J.fc.currentSuggestion == "otherSuggestions"){
					J.fc.grid.removeOtherSuggestions('user');
				}
            }
        }],
        admin: [{
            text: tr('play'),
            handler: function(){
                J.fc.grid.addToPlayer(true, null, true);
            }
        }, {
            text: tr('enqueue'),
            handler: function(){
                J.fc.grid.addToPlayer(true, null, false);
            }
        }, {
            text: tr('addToNewPlaylist'),
            handler: function(){
                J.fc.grid.addToNewPlaylist(true);
            }
        }, {
            text: tr('addToPlaylist'),
            handler: function(){
                J.fc.grid.addToPlaylist(true);
            }
        }, {
            text: "Supprimer",
            handler: function(){
                if(J.fc.currentSuggestion == "suggestions"){
					J.fc.grid.removeMySuggestion('user');
				}else if(J.fc.currentSuggestion == "otherSuggestions"){
					J.fc.grid.removeOtherSuggestions('user');
				}
            }
        }]
    }
});
J.View.AlbumGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'play',
            width: 25,
            sortable: false,
            renderer: J.render.playButtonRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'albumId',
            clickableAfterExpand: true,
            width: 75,
			cls:'grid-picture',
            sortable: true,
            dataIndex: 'albumId',
            header: " ",
            renderer: J.render.albumPictureRenderer
        });
		
		columns.push({
            id: 'albumName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'albumName',
            header: "Nom de l'album",
            renderer: J.render.albumNameRenderer
        });
		
		columns.push({
            id: 'artistName',
            expand: true,
            width: 150,
            sortable: true,
            dataIndex: 'artistName',
            header: "Artiste(s)",
            renderer: J.render.artistNameRenderer
        });
			
        columns.push({
            id: 'releaseDate',
            expand: true,
            width: 90,
            sortable: true,
            dataIndex: 'releaseDate',
            header: "Sortie le",
			type:'date',
			dateFormat: 'Y-m-d H:i:s',
			renderer:J.render.dateRenderer
        });
		
		columns.push({
	            id: 'albumPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'albumPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.popularityRenderer
	        });

        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/album/100/{albumId}.jpg';
        // define a template to use for the detail view
        p.cls = "jListGrid";
        p.enableHdMenu = false;
        
        J.View.AlbumGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "play":
                J.fc.getController("player", true).jwAddAlbum(record.data.albumId, {
                    play: true
                });
				
		   return false;
            break;

            default:
                console.warn("Mousedown on ", fieldName);
                return true;
        }
    },
	optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('album_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('album');
				}
            },{
                id: "unsubscribe",
                text: tr('album_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('album');
				}
            }
		],
		admin: [
		 ]
	}
	
});
J.View.ArtistGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'play',
            width: 25,
            sortable: false,
            renderer: J.render.playButtonRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'artistId',
            clickableAfterExpand: true,
            width: 75,
			cls:'grid-picture',
            sortable: true,
            dataIndex: 'artistId',
            header: " ",
            renderer: J.render.artistPictureRenderer
        });
		
		columns.push({
            id: 'artistName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            sortable: true,
            dataIndex: 'artistName',
            header: "Artiste(s)",
            renderer: J.render.artistNameRenderer
        });
		
		
       
		columns.push({
	            id: 'artistPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'artistPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.popularityRenderer
	        });

        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/artist/100/{artistId}.jpg';
        // define a template to use for the detail view
        p.cls = "jListGrid";
        p.enableHdMenu = false;
        
        J.View.AlbumGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "play":
                J.fc.getController("artist", true).play(record.data.artistId);
				
		   return false;
            break;

            default:
                console.warn("Mousedown on ", fieldName);
                return true;
        }
    },
	optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('artist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('artist');
				}
            },{
                id: "unsubscribe",
                text: tr('artist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('artist');
				}
            }
		],
		admin: [{
                id: "subscribe",
                text: tr('artist_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('artist');
				}
            },{
                id: "unsubscribe",
                text: tr('artist_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('artist');
				}
            }
		]
	}
	
});
J.View.UserGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'play',
            width: 25,
            sortable: false,
            renderer: J.render.playButtonRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'userId',
            width: 75,
			cls:'grid-picture',
            sortable: true,
            dataIndex: 'userId',
            header: " ",
            renderer: J.render.userPictureRenderer
        });
		

		
		columns.push({
            id: 'userName',
            colWidth: 1,
            sortable: true,
            dataIndex: 'userName',
            header: "Nom",
            renderer: J.render.userNameRenderer
        });
		
        columns.push({
            id: 'age',
            expand: true,
            width: 90,
            sortable: true,
            dataIndex: 'age',
            header: "Age",
			renderer:J.render.ageRenderer
        });
		
				columns.push({
	            id: 'userPopularity',
	            width: 57,
	            sortable: true,
				expand: true,
	            dataIndex: 'userPopularity',
	            header: "<div class='jGrid-icon-coeur'></div> ",
	            renderer: J.render.popularityRenderer
	        });

        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/user/100/{userId}.jpg';
        // define a template to use for the detail view
        p.cls = "";
        p.enableHdMenu = false;
        
        J.View.UserGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "play":
				J.fc.getController("user", true).play(record.data.userId, record.data.userName);
			 break;
       
        }
    },
	 expandHandler: function(rowExpander, record, row, body) {
     if (this.rowExpanderPanel){
	   	this.rowExpanderPanel.body.update('');
	   }
	   
	    var htmlRightActions = "", htmlLeftActions = "", data = record.data;
        
        
        // actions
		var swap =false;
		
		
        Ext.each(rowExpander.grid.getExpandActions(data, record, row), function(action) {
            if(swap){
				
				htmlRightActions += this.RenderAction(action);
				
			}else{
				
				htmlLeftActions += this.RenderAction(action);
			}
			swap = (!swap);
			
        },this);
        
        xxx = rowExpander;
		

		this.rowExpanderPanel = new Ext.Panel({
		    layout:'column',
			renderTo :body,
			cls :"expandedRow",
			border:false,
		    items: [{
		      columnWidth: 1/2,
			  border:false,
			  cls :"jGrid-actions",
			  html :htmlLeftActions
		    },{
		      columnWidth: 1/2,
			  cls :"jGrid-actions",
			  border:false,
			  html :htmlRightActions
		    }]
		});
		
    }
	 , getExpandActions: function(data) {
        return ["addtoMyFriends", "addtoMyAngels", "Delete", "litenRadio", "card"];
    },
	optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('user_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('user');
				}
            },{
                id: "unsubscribe",
                text: tr('user_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('user');
				}
            }
		],
		admin: [
			{
                id: "subscribe",
                text: tr('user_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('user');
				}
            },{
                id: "unsubscribe",
                text: tr('user_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('user');
				}
            }
		]
	}
});
J.View.RadioGrid = Ext.extend(J.View.JGrid, {
	
    constructor: function(p) {
        var columns = [];
		
	columns.push({
        id: 'actions',
        width: 3 * 20+15,
		 sortable: false,
        renderer: J.render.actionsRenderer,
		expand: false,
        resizable: false,
        header: "<div class='row'><div class='icon play play-All'></div><div class='icon enqueue enqueue-All'></div><div class='icon add add-All'></div></div>"
    });

    columns.push({
            id: 'artistName',
            expand: true,
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'artistName',
            header: tr('trackGrid_header_artistName'),
            renderer: J.render.artistNameRenderer
        });
        columns.push({
            id: 'songName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'songName',
            header: "Titre",
            renderer: J.render.songNameRenderer
        });
        columns.push({
            id: 'albumName',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'albumName',
            header: tr('trackGrid_header_albumName'),
            renderer: J.render.albumNameRenderer
        });
        columns.push({
            id: 'songPopularity',
            width: 57,
            sortable: true,
            dataIndex: 'songPopularity',
            header: "<div class='jGrid-icon-coeur'></div> ",
            renderer: J.render.songPopularityRenderer
        });
        
        p.columns = columns;
        
        // define a template to use for the detail view
        p.actions = [["play", "video"], ["enqueue", "suggest"], ["addToPlaylist", "buzz"], ["addToNewPlaylist"]];
        p.cls = "trackGridView";
        p.enableHdMenu = false;
		
        J.View.TrackGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
		
		this.body.child('.play-All').on('click', this.onPlayAll, this);
    	this.body.child('.add-All').on('click', this.onAddAll, this);
   		this.body.child('.enqueue-All').on('click', this.onEnqueueAll, this);
        this.on('jCellClick', this.onCellClick, this);
    },

    expandHandler: function(rowExpander, record, row, body) {

	   
	    var htmlRightActions = "", htmlLeftActions = "", htmlInfos = "", data = record.data;
        
        // infos
        Ext.each(rowExpander.grid.getExpandInfos(data, record, row), function(info) {
            htmlInfos += this.RenderInfos(info.label, info.html);
        },this);
        
        // actions
		var swap =false;
		
		
        Ext.each(rowExpander.grid.getExpandActions(data, record, row), function(action) {
            if(swap){
				
				htmlRightActions += this.RenderAction(action);
				
			}else{
				
				htmlLeftActions += this.RenderAction(action);;
			}
			swap = (!swap);
			
        },this);
        
        xxx = rowExpander;
		
		rowExpander.grid.illustrationUrl = J.MEDIAPATH + '/album/100/{albumId}.jpg';
		
		rowExpander.grid.illustrationUrl =rowExpander.grid.illustrationUrl.replace("{albumId}", data.albumId);
 
		this.rowExpanderPanel = new Ext.Panel({
		    layout:'column',
			renderTo :body,
			cls :"expandedRow",
			border:false,
		    items: [{
		        columnWidth: 1/6 ,
				border:false,
				cls:"jGrid-illustration-wrapper",
				html : '<div class="jGrid-illustration" style="background: black"><img src="'+ rowExpander.grid.illustrationUrl+'" height=50 width=50/></div>'
		    },{
		      columnWidth: 1/6,
			  border:false,
			  cls :"jGrid-infos",
			  html :htmlInfos
		    },{
		      columnWidth: 1/3,
			  border:false,
			  cls :"jGrid-actions",
			  html :htmlLeftActions
		    },{
		      columnWidth: 1/3,
			  cls :"jGrid-actions",
			  border:false,
			  html :htmlRightActions
		    }]
		});
		
	

    },
    getExpandInfos: function(data) {
        return [{
            label: "trackDate",
            html: data.albumReleaseDate
        }, {
            label: tr('select_themes'),
            html: ' : '+data.albumGenre
        }];
    },
    getExpandActions: function(data) {
        return ["play", "video", "enqueue", "suggest", "addToPlaylist", "buzz", "addToNewPlaylist"];
    }
});
J.View.MailGrid = Ext.extend(J.View.JList, {
	
    constructor: function(p) {
        var columns = [];
        columns.push({
            id: 'flag',
            width: 25,
			dataIndex: 'readFlag',
            sortable: true,
            renderer: J.render.flagRenderer,
            header: "",
            expand: false
        });
		
		columns.push({
            id: 'userId',
            colWidth: 1,
            sortable: true,
            dataIndex: 'userId',
            header: tr("sendMail_label_from"),
            renderer: J.render.userPreviewRenderer,
			expand: false
        });
		
		columns.push({
            id: 'subject',
            expand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'subject',
            header: tr("sendMail_label_sujet"),
			renderer: J.render.subjectPreviewRenderer,
			expand: false
        });
		
		columns.push({
            id: 'date',
            width: 140,
            sortable: true,
            dataIndex: 'sentTimestamp',
            header: tr("sendMail_label_date"),
			type:'date',
			dateFormat: 'Y-m-d H:i:s',
			renderer:J.render.dateRenderer,
			expand: false
        });
		


        p.columns = columns;
        // define a template to use for the detail view
        p.cls = "";
        p.enableHdMenu = false;
        
        J.View.MailGrid.superclass.constructor.call(this, p);
        
       
        this.on('jCellClick', this.onCellClick, this);
    },
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
         J.fc.gotoUrl('account','mails','read',record.data.inMailId);
        
    },
	 expandHandler: function(rowExpander, record, row, body) {

		
    },
	optionsActionMenu: {
		normal: [
			{
				text: tr('delete'),
				handler: function(){
					J.fc.jList.removeItem("mail");
				}
			}],
		admin: [
			{
				text: tr('delete'),
				handler: function(){
					J.fc.jList.removeItem("mail");
				}
			}]
	}
});
J.View.MailSendGrid = Ext.extend(J.View.JGrid, {
	
    constructor: function(p) {
        var columns = [];

		columns.push({
            id: 'recipientsNamesPreview',
            clickableAfterExpand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'recipientsNamesPreview',
            header: "Pseudo",
            renderer: J.render.recipicentPreviewRenderer,
			expand: false
        });
		
		columns.push({
            id: 'subject',
            expand: true,
            colWidth: 1,
            sortable: true,
            dataIndex: 'subject',
            header: "Sujet",
			renderer: J.render.subjectPreviewRenderer,
			expand: false
        });
		
		columns.push({
            id: 'date',
            width: 140,
            sortable: true,
            dataIndex: 'sentTimestamp',
            header: "Envoyé le",
			type:'date',
			dateFormat: 'Y-m-d H:i:s',
			renderer:J.render.dateRenderer,
			expand: false
        });
		


        p.columns = columns;
        p.illustrationUrl = J.MEDIAPATH + '/user/100/{userId}.jpg';
        // define a template to use for the detail view
        p.cls = "";
        p.enableHdMenu = false;
        
        J.View.MailSendGrid.superclass.constructor.call(this, p);
        
        this.addEvents({
            play: true,
            enqueue: true
        });
        this.on('jCellClick', this.onCellClick, this);
    },
	
	
    onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected) {
        switch (fieldName) {
            case "userId":
                
				J.fc.gotoUrl('user',record.data.userId);
            break;
       
            default:
              	 J.fc.gotoUrl('account','mails','send',record.data.outMailId);
            break;
        }
    },
	 expandHandler: function(rowExpander, record, row, body) {

		
    },
	optionsActionMenu: {
		normal: [
			{
				text: tr('delete'),
				handler: function(){
					J.fc.grid.removefromPlaylist(true);
				}
			}]
	}
});
J.View.AdminNewsGrid = Ext.extend(J.View.JGrid, {
    constructor: function(p){
    
        p.columns = [{
            id: 'title',
            sortable: false,
            dataIndex: 'title',
            header: "Title",
			renderer : J.render.newsRenderer,
            colWidth: 1
        }, {
            id: 'publishDate',
            width: 170,
            sortable: true,
            dataIndex: 'publishDate',
			clickableAfterExpand: true,
            header: "publishDate",
            renderer: J.render.date
        },        {
         id: 'provider',
         width: 100,
         sortable: true,
         dataIndex: 'provider',
		  clickableAfterExpand: true,
         header: "Source"
         }];
        
        p.cls = "trackGridView";
        p.enableHdMenu = false;
        
        J.View.AdminNewsGrid.superclass.constructor.call(this, p);
       
        this.on('jCellClick', this.onCellClick, this);
        
    },
	
   expandHandler: function(rowExpander, record, row, body) {

	   
	    var htmlRightActions = "", htmlLeftActions = "", htmlInfos = "", data = record.data;
        
        // infos
		
		var infos = rowExpander.grid.getExpandInfos(data, record, row);
        Ext.each(infos, function(info) {
            htmlInfos += this.RenderInfos(info.html);
        },this);
        
        // actions
		var swap =true;
		
		
        Ext.each(rowExpander.grid.getExpandActions(data, record, row), function(action) {
            if(swap){
				htmlLeftActions += this.RenderAction(action);
				
			}else{
				
				htmlRightActions += this.RenderAction(action);
				 
			}
	
				swap = !swap;
			
        },this);
        
        xxx = rowExpander;
		
		
		  if (infos.length == 0) {
            htmlInfos = '';
        }
        
        this.rowExpanderPanel = new Ext.Panel({
            layout: 'column',
            renderTo: body,
            cls: "expandedRow",
            border: false,
            items: [{
                width: 75,
                border: false,
                cls: "jGrid-illustration-wrapper",
                html: '<div class="jGrid-illustration" style="background: black"><img src="' + J.MEDIAPATH + '/news/50/'+data.newsId+'.jpg'+ '" width=50/></div>'
            }, {
                width: 300,
                border: false,
                cls: "jGrid-infos",
                html: htmlInfos
            }, {
                width: 90,
                border: false,
                cls: "jGrid-actions",
                html: htmlLeftActions
            }, {
                width: 90,
                cls: "jGrid-actions",
                border: false,
                html: htmlRightActions
            }]
        });
        

    },

   getExpandInfos: function(data) {
		
		infos = [];
		
		if(data.title){
			infos.push({
            	html: '<b>'+J.render.reduce(data.title,100)+'</b>'
        	});
		}
		
		if(data.thread){
			infos.push({
            	html : J.render.reduce(data.thread,150)
        	});
		}
		
        return infos;
    },
    getExpandActions: function(news){
        var state = news.state;
        var actions = [];
        
        switch (state) {
			 case -1:
				actions.push("edit");
				actions.push("preview");
                actions.push("validate");
				actions.push("delete");
            break;
            case 0:
				actions.push("edit");
				actions.push("preview");
                actions.push("validate");
                actions.push("reject");
                break;
            case 1:
				actions.push("edit");
				actions.push("preview");
                actions.push("validate");
                actions.push("reject");
            break;
            case 2:
                actions.push("edit");
			    actions.push("validate");
                actions.push("reject");
                actions.push("preview");
                break;
            case 3:
                actions.push("edit");
				actions.push("reject");
                actions.push("preview");
           break;
        }
        return actions;
    },
	  onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected,cls) {
        switch (fieldName) {
			case "preview":
					J.fc.gotoUrl('news',record.data.newsId);	
			break;
	
			case "create":	
				J.fc.getController('adminNews',true).create(record.data);
			break;
			
			case "delete":
				J.fc.getController('adminNews',true).model.reqDelete(record.data.newsId,grid.store);
			break;
			
			case "edit":
				J.fc.getController('news',true).edit(record.data);
			break;
			case "validate":
				J.fc.getController('adminNews',true).model.reqValidate(record.data.newsId,grid.store);
			break;
			
			case "reject":
				J.fc.getController('adminNews',true).model.reqReject(record.data.newsId,grid.store);
			break;
			
			
		}
		
		
		return true;
    },optionsActionMenu: {
		normal: [
			{
                id: "subscribe",
                text: tr('album_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('album');
				}
            },{
                id: "unsubscribe",
                text: tr('album_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('album');
				}
            }
		],
		admin: [{
                id: "subscribe",
                text: tr('album_add_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.subscribe('album');
				}
            },{
                id: "unsubscribe",
                text: tr('album_remove_to_favourite'),
				handler: function(el,nav){
					J.fc.jList.unSubscribe('album');
				}
            }
		]
	}
});
J.View.AdminTradToolGrid = Ext.extend(J.View.JGrid, {
    constructor: function(p){
        p.columns = [{
            id: 'translationLabelName',
            sortable: true,
            dataIndex: 'translationLabelName',
            header: "Label Name",
			renderer : J.render.newsRenderer,
            colWidth: 1,
			expand:false
        }, {
            id: 'translation',
            width: 280,
            sortable: true,
            dataIndex: 'translation',
            header: "Translation",
            renderer: J.render.newsRenderer,
			expand:false
        }, {
	         id: 'description',
	         width: 150,
	         sortable: false,
	         dataIndex: 'description',
	         header: "Description",
			 expand:false
         }];
        
        p.enableHdMenu = false;
        
        J.View.AdminTradToolGrid.superclass.constructor.call(this, p);
		this.on('jCellClick', this.onCellClick, this);
       
        
    },
	
	optionsActionMenu: {
		normal: [
			{
                id: "delete",
                text: tr('delete_translation'),
				handler: function(el,nav){
					J.fc.grid.removeTranslation('adminTradTool');
				}
            }
		],
		admin: [
			{
                id: "delete",
                text: tr('delete_translation'),
				handler: function(el,nav){
					J.fc.grid.removeTranslation('adminTradTool');
				}
        	}
		]
	},
	onCellClick: function(grid, record, fieldName, rowExpanded, rowSelected, cls){
		//Pour eviter l'ouverture de la boite d'edition lorsqu'on veut cocher la case en fin de ligne
		if (fieldName != "checker") {
			J.fc.getController('adminTradTool', true).edit(record.data);
		}
	}
});
J.View.Base = function(p){
	if(p.controller) {	
			this.controller = p.controller;
	}
	
	this.zone = J.fc.getZone("content");
	this.rendered =false;

	if(p.controller) {	
		this.controller = p.controller;	
	}
};

J.View.Base.prototype = {
	menu : {
		normal:{},
		admin:{}
	}, 
 	getAds: function(){
    
				var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=v&image=true&language="+J.Language.languageCode+"&urlContent="+url;
				
				return '<center><iframe  SRC="' + srcBan + '" WIDTH="130" height="620" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe></center>';
				
				
    
    },
	getMenu: function(category){
	 
	 	if(category){
			
			if(this.controller.mine()){
				
				if(this.menu.admin[category]){
					return this.menu.admin[category];
				}
			}else{
				
				if(this.menu.normal[category]){
					return this.menu.normal[category];
				}
				
			}
         
        }
		
		return [];
    },
	destroy: function() {
		this.rendered =false;
		if (this.panel) {
			this.panel.destroy();
		}
	}
};

J.View.Card = Ext.extend(J.View.Base, {
    actions: [],
    isFan: 'Retirer de mes abonnements',
    isNotFan: "Ajouter  à mes abonnements",
    tplPanel: '<table cellpadding=0 cellspacing=0 width="100%">' +
    '<tr><td width="681">' +
    
    '<table cellpadding=0 cellspacing=0 class="detail-header">' +
    '<tr>' +
    '<td class="detail-header-left">' +
    '</td>' +
    '<td class="detail-header-title" ><table width="100%"><tr><td idth="100%" id ="detail-header-title"></td ></tr></table></td>' +
    '<td class="detail-header-right">' +
    '</td>' +
    '</tr>' +
    '</table>' +
    
    '</td>' +
    '<td>' +
    '</td>' +
    
    '</tr>' +
    
    '<tr  height="100%"><td>' +
    '<table cellpadding=0 cellspacing=0 id="detail-summary" height="100%" class="detail-summary">' +
    '<tr>' +
    '<td id="detail-col-illustration" >' +
    '<div>' +
    '<div id="illustrationWrapper" >' +
    '<div  class="cadre">' +
    '<div class="cadre-top"></div>' +
    '<div class="illustrationWrapper">' +
    '<img  id="illustration" width="131"  />' +
    '<div class="cadre-bottom"></div>' +
    '</div>' +
    '</div>' +
    '</div>' +
    '</div>' +
    '</td>' +
    '<td id="detail-top-content" height="100%" >' +
    '<div id="detail-col-infos" >' +
    '</div>' +
    '<div id="detail-col-actions" class="button-actions">' +
    '</div>' +
    '</td>' +
    '</tr>' +
    
    '<tr>' +
    '<td id="detail-col-illustration-no-img" >' +
    '</td>' +
    '<td id="detail-top-content">' +
    '<div id="detail-col-down">' +
    '</div >' +
    '</td>' +
    '</tr>' +
    '<tr>' +
    '<td colspan="2" id="main-top-cardView">' +
    '</td>' +
    '</tr>' +
    '</table>' +
    '</td>' +
    '<td class="top-col" >' +
    '<div class="detail-categories-top"></div>' +
    '<div id="detail-permalien" class="detail-col-categories" ></div>' +
    '<div class="detail-categories-bottom"></div>' +
    '</td>' +
    '</tr>' +
    // separator
    
    
    
    // content
    '<tr id="detail-row-bottom">' +
    
    '<td id="detail-col-bodyWrapper" >' +
    '<table cellpadding=0 cellspacing=0>' +
    '<tr>' +
    '<td id="detail-col-title" class ="body-title">' +
    '</td>' +
    '<td id="actionMenu">' +
    '</td>' +
    '</tr>' +
    '</table>' +
    '<div id="detail-col-body">' +
    '</div>' +
    '</td>' +
    '<td id="detail-col-categoriesWrapper">' +
	
	'<div id="detail-categories">'+
    '<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="detail-col-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	'</div>'+
	
	  '<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	
    '</td>' +
    '</tr>' +
    
    
    '<tr>' +
    
    '<td>' +
    // footer
    '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
    '<tr>' +
    '<td class="detail-footer-left">' +
    '</td>' +
    '<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
    tr("gotoupperPage") +
    '</td>' +
    '<td class="detail-footer-right">' +
    '</td>' +
    
    '</tr>' +
    '</table>' +
    
    '</td>' +
    '<td >' +
    '</td>' +
    '</tr>' +
    '</table>',
    addAction: function(){
    
    
    },
    getContentBody: function(){
    
        this.body = this.panel.body.child("#detail-col-body");
        this.body.update("");
        return this.body.createChild({});
    },
    render: function(){
    
    
        if (this.controller.isExportable()) {
        
            /*Création du template de la zone Permalien*/
            this.tplPermalien = new Ext.XTemplate('<div class="cardview-rightpannel-bloc cardview-rightpannel-separation cardview-rightpannel-permalien">' +
            '<div class="cardview-rightpannel-title">' +
            tr('soe_permalien') +
            ' :</div>' +
            '<div><input type="text" class="cardview-rightpannel-input" value="{sUrlPermalink}" /></div>' +
            '<div><span onclick="J.fc.controller.permalink()">' +
            tr('soe_permalien_copy') +
            '</span></div>' +
            '</div>' +
            '<div class="cardview-rightpannel-bloc cardview-rightpannel-separation cardview-rightpannel-player">' +
            '<div class="cardview-rightpannel-title">' +
            tr('soe_player_exportable') +
            ' :</div>' +
            "<div><input type='text' class='cardview-rightpannel-input' value='{sUrlPlayerlink}' /></div>" +
            '<div><span onclick="J.fc.controller.playerlink()">' +
            tr('soe_player_copy') +
            '</span></div>' +
            '</div>' +
            '<div class="cardview-rightpannel-bloc cardview-rightpannel-perso">' +
            '<div></div>' +
            '<div class="cardview-rightpannel-perso-text">' +
            tr('soe_personalise') +
            '</div>' +
            '<div><span onclick="J.fc.controller.widget()">' +
            tr('soe_personalise_link') +
            '</span></div>' +
            '</div>', J.render);
            
        }
        else {
        
            this.tplPermalien = new Ext.XTemplate('<div class="cardview-rightpannel-bloc cardview-rightpannel-separation cardview-rightpannel-permalien">' +
            '<div onclick="J.fc.controller.share()" class="cardview-rightpannel-title">' +
            tr('seo_share') +
            ' </div>' +
            '<div><span onclick="J.fc.controller.share()">' +
            tr('seo_share_' + this.controller.baseUrl) +
            '</span></div>' +
            '</div>' +
            '<div class="cardview-rightpannel-bloc cardview-rightpannel-permalien">' +
            '<div class="cardview-rightpannel-title">' +
            tr('soe_permalien') +
            ' :</div>' +
            '<div><input type="text" class="cardview-rightpannel-input" value="{sUrlPermalink}" /></div>' +
            '<div><span onclick="J.fc.controller.permalink()">' +
            tr('soe_permalien_copy') +
            '</span></div>' +
            '</div>' +
            '</div>', J.render);
            
            
        }
        
        
        
        this.panel = new Ext.Panel({
            cls: "detail",
            renderTo: this.zone,
            anchor: '100%',
            border: false,
            html: this.tplPanel
        
        
        });
        
        
        
        
        
        this.categoriePanel = new Ext.Panel({
            width: '140',
            
            renderTo: "detail-col-categories"
        });
        // Categories
        var categoriesRenderTo = this.categoriePanel.body;
        this.categories = {};
        
        
        if (this.options.categories.length > 0) {
            Ext.each(this.options.categories, function(category){
            
                this.categories[category.id] = new Ext.SimpleButton({
                    text: tr(category.text),
                    buttonId: category.id,
                    renderTo: categoriesRenderTo,
                    enableToggle: true,
                    toggleGroup: "details-categories",
                    toggleHandler: this.categoryHandler,
                    scope: this
                });
            }, this);
        }
        else {
            Ext.get("detail-categories").update("");
        }
        
        
        
        this.contentEl = Ext.get("detail-col-infos");
        this.mainTopCardView = Ext.get("main-top-cardView");
        this.titleEl = Ext.get("detail-header-title");
        this.imageEl = Ext.get("illustration");
        this.bodyTitle = Ext.get("detail-col-title");
        
        var ButtonRenderTo = this.panel.body.child("#detail-col-illustration");
        
        if (ButtonRenderTo) {
            this.btnZoneUnderPicture = ButtonRenderTo.createChild({
                id: 'detail-col-illustration-btn-zone'
            });
            this.textUnderPicture = ButtonRenderTo.createChild({
                html: "Découvrir un artiste similaire",
                id: 'title-under-picture'
            });
        }
        
        
        
         Ext.get("pub-categories").update(this.getAds());
        
        
    },
    renderTags: function(){
        var el = this.panelPlaylist.body.child('.tags');
        if (el) {
            el.update(this.formatTags(this.obj.tags));
        }
    },
    formatTags: function(tags){
        if (!tags || !tags.length) {
            return '';
        }
        var ans = '';
        for (var i = 0, l = tags.length; i < l; i++) {
            var tag = tags[i];
            var hrefTag = J.fc.gotoUrl("search", "playlist", {
                q: tag
            });
            ans += '<a href=' + hrefTag + ' class="tag">' + tag + '</a> ';
        }
        return ans;
    },
    showSubscribe: function(){
    
        this.actions["subscribe"].setVisibilityMode(Ext.Element.DISPLAY).show();
        this.actions["unsubscribe"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        
    },
    showUnSubscribe: function(){
    
        this.actions["subscribe"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        this.actions["unsubscribe"].setVisibilityMode(Ext.Element.DISPLAY).show();
        
    },
	showOptionHidden: function(){
    
        this.actions["hidden"].setVisibilityMode(Ext.Element.DISPLAY).show();
        this.actions["display"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        
    },
	showOptionDisplay: function(){
    
        this.actions["hidden"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        this.actions["display"].setVisibilityMode(Ext.Element.DISPLAY).show();
        
    },
	showOptionRestrict: function(){
    
        this.actions["edit-restriction"].setVisibilityMode(Ext.Element.DISPLAY).show();
        this.actions["edit-not-restriction"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        
    },
	showOptionAllow: function(){
    
        this.actions["edit-restriction"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        this.actions["edit-not-restriction"].setVisibilityMode(Ext.Element.DISPLAY).show();
        
    },

	showSelectRecommendation: function (){
		this.actions["edit-recommendation-check"].setVisibilityMode(Ext.Element.DISPLAY).show();
        this.actions["edit-recommendation-uncheck"].setVisibilityMode(Ext.Element.DISPLAY).hide();
	},
	showUnSelectRecommendation: function (){
		this.actions["edit-recommendation-check"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        this.actions["edit-recommendation-uncheck"].setVisibilityMode(Ext.Element.DISPLAY).show();
	},
    showDownload: function(){
    
        this.actions["download"].setVisibilityMode(Ext.Element.DISPLAY).show();
        
    },
    showUnDownload: function(){
    
        this.actions["download"].setVisibilityMode(Ext.Element.DISPLAY).hide();
        
    },
    showSummary: function(){
        Ext.get("detail-summary").setVisibilityMode(Ext.Element.DISPLAY).show();
        
    },
    hideSummary: function(){
        Ext.get("detail-summary").setVisibilityMode(Ext.Element.DISPLAY).hide();
    },
   setContent: function(content){
    
    
        var tpl = new Ext.XTemplate(this.tplContent, J.render);
        
        tpl.overwrite(this.contentEl, content);
        
        J.Seo.init(content, this.controller.baseUrl);
		
	
          
    },
    setTopViewCard: function(aDataTpl){
        if (this.displayTop) {
        
            //Création des trois blocs pour les TOP
			this.mainTopCardView.update("");
            var topLeft = this.mainTopCardView.createChild({
                cls: 'viewCard-top-left'
            });
            var topCenter = this.mainTopCardView.createChild({
                cls: 'viewCard-top-center'
            });
            var topRight = this.mainTopCardView.createChild({
                cls: 'viewCard-top-right'
            });
            
            //récupération des Template
            var tplTopLeft = J.Template.topViewCard(this.displayTop.left.index);
            var tplTopCenter = J.Template.topViewCard(this.displayTop.center.index);
            var tplTopRight = J.Template.topViewCard(this.displayTop.right.index);
            
            //Insertion des TPL dans les zones
            if (tplTopLeft) {
                aDataTpl.left.title = this.displayTop.left.title;
                tplTopLeft.overwrite(topLeft, aDataTpl.left);
            }
            if (tplTopCenter) {
                aDataTpl.center.title = this.displayTop.center.title;
                tplTopCenter.overwrite(topCenter, aDataTpl.center);
            }
            if (tplTopRight) {
                aDataTpl.right.title = this.displayTop.right.title;
                tplTopRight.overwrite(topRight, aDataTpl.right);
            }
            
            return true;
            
        }
        else {
            return false;
        }
    },
    setImage: function(image){
    
        if (this.controller.mine()) {
            this.imageEl.dom.src = image + '?r=' + Math.random();
        }
        else {
            this.imageEl.dom.src = image;
        }
        
    },
    setTitle: function(){
      //  this.titleEl.update(tr(this.controller.baseUrl + '_card'));
    },
    setActiveCategory: function(buttonId){
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        }else if (this.activeButton) {
                this.activeButton.toggle(false);
            }
    },
    
    /**
     * Toggle handler of the categories (on the left)
     * @param {Object} button
     * @param {Boolean} state
     */
    categoryHandler: function(button, state){
        if (state) {
            this.activeButton = button;
            this.setBodyTitle(button.text);
            this.controller.categoryChangeHandler(button.buttonId);
        }
		
		 Ext.get("pub-categories").update(this.getAds());
    },
    
    setBodyTitle: function(text){
        this.bodyTitle.update(tr(text));
    },
    refreshAction: function(){
        // Actions
        var actionsRenderTo = this.panel.body.child("#detail-col-actions");
        var ButtonRenderTo = this.panel.body.child("#detail-col-illustration-btn-zone");
        
        var data = this.controller.SoeExtractInfo();
        this.tplPermalien.overwrite('detail-permalien', data);
        
        if (ButtonRenderTo) {
            ButtonRenderTo.update("");
            
            if (this.options.subs.length > 0) {
                var itemFocus = this;
                Ext.get('title-under-picture').update('');
                Ext.each(this.options.subs, function(menu){
                
                    var button = new Ext.SimpleButton({
                        renderTo: ButtonRenderTo,
                        id: menu.id,
                        width: 23,
                        handler: this.actionHandler,
                        listeners: {
                            mouseover: this.updateDescription,
                            scope: this
                        },
                        scope: this
                    });
                    
                    if (menu.admin == true) {
                        if (!this.controller.mine()) {
                            button.disable();
                        }
                    }
                }, this);
                
            }
            else {
                ButtonRenderTo.remove();
            }
        }
        
        if (actionsRenderTo) {
        
            actionsRenderTo.update("");
            
            var first = "first";
            if (!this.controller.mine()) {
            
                if (this.options.actions.length > 0) {
                
                    Ext.each(this.options.actions, function(action){
                    
                        this.actions[action.id] = actionsRenderTo.createChild({
                            html: tr(action.text),
                            id: action.id,
                            cls: "puce-col-actions " + first
                        });
                        
                        this.actions[action.id].on('click', this.actionHandler, this);
                        
                        first = "";
                        
                    }, this);
					
                    
                    if (this.actions["subscribe"] != undefined) {
                    
                        if (this.controller.isFan()) {
                            this.showUnSubscribe();
                            
                        }
                        else {
                            this.showSubscribe();
                        }
                        
                    }
                    
                    if (this.actions["download"] != undefined) {
                    
                        if (this.controller.isDownload()) {
                            this.showDownload();
                        }
                        else {
                            this.showUnDownload();
                        }
                        
                    }
                    
                }
                else {
                    actionsRenderTo.remove();
                }
                
                
            }
            else {
            
                if (this.options.admin.length > 0) {
                    Ext.each(this.options.admin, function(action){
                    
                        this.actions[action.id] = actionsRenderTo.createChild({
                            html: tr(action.text),
                            id: action.id,
                            cls: "puce-col-actions " + first
                        });
                        
                        this.actions[action.id].on('click', this.actionHandler, this);
                        
                        first = "";
                        
                    }, this);
					
					if (this.options.staff != undefined) {
						if (isStaff() == true) {
							Ext.each(this.options.staff, function(action){
							
								this.actions[action.id] = actionsRenderTo.createChild({
									html: tr(action.text),
									id: action.id,
									cls: "puce-col-actions " + first
								});
								
								this.actions[action.id].on('click', this.actionHandler, this);
								
							}, this);
						}
					}
					
					
					if (this.actions["subscribe"] != undefined) {
                    
                        if (this.controller.isFan()) {
                            this.showUnSubscribe();
                            
                        }
                        else {
                            this.showSubscribe();
                        }
                        
                    }
					
					if (this.actions["edit-recommendation-check"] != undefined) {
                    
                        if (this.controller.isRecommendate()) {
                            this.showUnSelectRecommendation();
                        }
                        else {
                            this.showSelectRecommendation();
                        }
                        
                    }
					if (this.actions["hidden"] != undefined) {
                    
                        if (this.controller.isHidden()) {
							this.showOptionDisplay();
                        }
                        else {
                            this.showOptionHidden();
                        }
                        
                    }
					if (this.actions["edit-restriction"] != undefined) {
	                    
                        if (!this.controller.isRestricted()) {
							this.showOptionRestrict();
                        }
                        else {
                            this.showOptionAllow();
                        }
                        
                    }
                    
                }
                else {
                    actionsRenderTo.remove();
                }
            }
            
        }
        
        
    },
    /**
     * Handler of the actions
     * @param {Object} button
     */
    actionHandler: function(nav, el){
        if (el.id != undefined) {
            this.controller.actionHandler(el.id);
        }
        else 
            if (nav.id != undefined) {
                this.controller.actionHandler(nav.id);
                
            }
    },
    updateDescription: function(nav, el){
        if (nav.id != undefined) {
            this.controller.updateDescription(nav.id, this.textUnderPicture);
        }
    }
});
J.View.Ad = function(options) {
	J.View.Ad.superclass.constructor.call(this,options);
	this.key = options.key;
	this.type = options.type;
	this.position = options.position; // Top, Left, etc
	this.zone = options.renderTo ? options.renderTo : J.fc.getZone(options.zone);
	this.renderAdTo = null;
	this.cls = options.cls ? (options.cls + " ") : "";
	this.controller = options.controller ? options.controller : null;
	this.adsense = options.adsense ? options.adsense : false;
};


Ext.extend(J.View.Ad, J.View.Base, {

	renderAdTo : null,	
	hidden: false,	
	getAdsUrls: function() {
			var srcBan;
			var srcSq;

			var isHome = document.location.hash=="#" || document.location.hash=="#home" || document.location.hash=="";
			
			
			/*
			 * if (jwPlayer) {
				if (jwPlayer.currentTrack) {
					switch (jwPlayer.currentTrack.ad) {
						case "playlist":
							srcBan = "/res/html/ads/FR-PLAYLIST-728x90.html";
								srcSq = "/res/html/ads/FR-PLAYLIST-300x250.html";
							return [srcBan, srcSq];
							break;
							
						case "radio":
							srcBan = "/res/html/ads/FR-RADIO-728x90.html";
							srcSq = "/res/html/ads/FR-RADIO-300x250.html";
							return [srcBan, srcSq];
							break;
							
					}
				}
			}
			*/
				
				
			//	if(country.code =='RE'){
			//	srcBan = "/res/html/ads/FR-RE-728x90.html";
			//		srcSq = "/res/html/ads/FR-RE-300x250.html";
					
			//	}else 
				
				if(this.adsense){
				
				var selectPub = Math.floor(Math.random()*this.controller.urlList.length);
				var url =this.controller.urlList[selectPub];
				
				srcBan = "/googleAds.php?format=h&image=true&language="+J.Language.languageCode+"&urlContent="+url+"&name="+J.fc.name;
				
				var selectPub = Math.floor(Math.random()*this.controller.urlList.length);
				var url =this.controller.urlList[selectPub];
				
				srcSq = "/googleAds.php?format=h&image=true&language="+J.Language.languageCode+"&urlContent="+url+"&name="+J.fc.name;
				
			}else if (isHome) {
				srcBan = "/res/html/ads/FR-HP-728x90.html";
				srcSq = "/res/html/ads/FR-HP-300x250.html";
			} else {
				srcBan = "/res/html/ads/FR-RG-728x90.html";
				srcSq = "/res/html/ads/FR-RG-300x250.html";
			}
			
			return [srcBan, srcSq];
				
			
	},
	init: function() {
		
		
			var urls = this.getAdsUrls();
			srcBan = urls[0];
			srcSq = urls[1];
			
			
		this.wrapperEl = this.zone.createChild({
			cls: this.cls + "ad"
		});
		
		switch (this.type) {
			case "megaBanner":
				this.renderAdTo = this.wrapperEl.createChild({
					
						html: '<iframe  id="iframe-'+this.type+'" SRC="' + srcBan + '" WIDTH="728" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=TOP ></iframe>'
				
				});
				break;
				
			case "horizontalBanner":
				this.renderAdTo = this.wrapperEl.createChild({
					
						html: '<center><iframe id="iframe-'+this.type+'" SRC="' + srcBan + '" WIDTH="468" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe></center>'
				
				});
				break;
			case "mediumRectangle":
				this.wrapperEl.createChild({
					cls: "ad-mediumRectangle-top"
				});
				this.renderAdTo = this.wrapperEl.createChild({
					cls: "ad-mediumRectangle-inside",
					html:'<iframe  SRC="' + srcSq + '"  id="iframe-'+this.type+'" WIDTH="300" HEIGHT="250" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=TOP ></iframe>'
        
				});
				this.wrapperEl.createChild({
					cls: "ad-mediumRectangle-bottom"
				});
				
				
				break;
			case "verticalBanner":
				this.renderAdTo = this.wrapperEl.createChild({
					
						html: '<center><iframe  id="iframe-'+this.type+'" SRC="' + srcBan + '" WIDTH="468" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe></center>'
				
				});
				break;
				
				
				
			default:
				throw Error("Unknown ad type");
				return;
		}
		
		return this.renderAdTo;

	},
	
	refresh: function() {
		
		if (this.renderAdTo) {
			var html = "";
			var urls = this.getAdsUrls();
			srcBan = urls[0];
			srcSq = urls[1];
			
			switch (this.type) {
				case "megaBanner":
					html = '<iframe   id="iframe-'+this.type+'" SRC="' + srcBan + '" WIDTH="728" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=TOP ></iframe>';
					break;
					
				case "horizontalBanner":
				html = '<center><iframe  id="iframe-'+this.type+'"  SRC="' + srcBan + '" WIDTH="468" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe></center>';
				break;	
				case "mediumRectangle":
					
					html = '<iframe   id="iframe-'+this.type+'" SRC="' + srcSq + '" WIDTH="300" HEIGHT="250" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=TOP ></iframe>';
					
					break;
				case "verticalBanner":
					html = '<iframe  id="iframe-'+this.type+'" SRC="' + srcBan + '" WIDTH="728" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=TOP ></iframe>';
					
					break;
				default:
					return;	
					break;
					}
			
			this.renderAdTo.update(html);
			
			 
		}
	}
	
});
J.View.MainMenu = function(options) {
	J.View.MainMenu.superclass.constructor.call(this,options);
    this.type = options.type;
    this.zone = J.fc.getZone(options.zone);
    //this.buttonsIds = ["home","radio","news","newReleases", 'top',"recommendation", "forum"];
	//this.buttonsIds = ["home","radio","top","community","forum"];
	this.buttonsIds = ["home","radio","newReleases","recommendation","community","forum","game"];
	
    this.buttons = new Ext.util.MixedCollection();
    this.buttonsEl = null;
    this.activeButton = null;

};

Ext.extend(J.View.MainMenu, J.View.Base, {
    MAINMENUWIDTH: 89,
  
    render: function() {

		this.zone.update('');
		this.topMenu = this.zone.createChild({
             	id: "zone-helpMenu",
				html :'<a onClick="J.fc.getController(\'account\',true).popupLogin();" >'+tr('mainMenu-connect')+
				'</a> <span class="puce"></span><a onClick="J.fc.getController(\'account\',true).popupSubscribe();" >'+
				tr('mainMenu-signup')+'</a>'
          });
		  
		
		
		J.fc.MenuView =this;
        	
		this.buttonMenu = [];			
        this.buttonsEl = this.zone.createChild({
            id: "mainMenu"
        });
        
        var i = 0;
        var nbButtons = this.buttonsIds.length;
        Ext.each(this.buttonsIds, function(buttonId) {
            // First and last buttons are wrapped into elements
            var wrapperCls = "mainMenu-buttonWrapper";
            var renderTo;
            if (i == 0) {
                wrapperCls += " x-btn-first";
            }
            if (i == nbButtons - 1) {
                wrapperCls += " x-btn-last";
            }
            if (wrapperCls) {
                renderTo = this.buttonsEl.createChild({
                    cls: wrapperCls
                });
            } else {
                renderTo = this.buttonsEl;
            }
            // Render elements
            var config = {
                cls: "mainMenu-button",
                minWidth: this.MAINMENUWIDTH,
                id: "mainMenu-button-" + buttonId,
                buttonId: buttonId,
                text: tr("mainMenu-" + buttonId),
                tooltip: tr("mainMenu-" + buttonId + "-tooltip"),
                renderTo: renderTo,
                scope: this
            };
			
            if (buttonId == "admin") {
                config.menu = this.adminMenu;
            }else if (buttonId == "forum") {
          
			  config.handler = function(){
			  	window.open("http://forum.jiwa.fm/");
			  
			  };
            }else {
                config.toggleGroup = "mainMenu-buttons";
                config.enableToggle = true;
                config.allowDepress = false;
				config.handler = function(event){
			  		J.fc.gotoUrl(buttonId);
			  };
            }
             this.buttonMenu[buttonId] = new Ext.Button(config);
            
            if (buttonId == "admin") {
                 this.buttonMenu[buttonId].menu.on("itemclick", function(item) {
                   this.controller.adminClickHandler(item.buttonId);
                }, this);
            } else {
				
                this.buttons.add(buttonId, this.buttonMenu[buttonId]);
				
            }
            i++;
        }, this);
        
    }
});
J.View.Player = function(options){
    J.View.Player.superclass.constructor.call(this, options);
    this.zone = J.fc.getZone(options.zone);
    this.playerBar = J.statusBar;
    this.albumCover = null;
    this.model = this.controller.model;
};

Ext.extend(J.View.Player, J.View.Base, {
    PROGRESS_MAX_WIDTH: 134,
    index: 0,
    totalTime: 0,
    mode: 'ON_DEMAND',
    radio: false,
	progressPast:null,
	progessFuture:null,
    paused: true,
    queueGrid: null,
    playWidth: 0,
    setProgress: function(currentTimeInt, maxTimeInt, currentTimeStr, maxTimeStr, ratio){
		
        this.timeCurrent.update(currentTimeStr);
        this.timeTotal.update(' / ' + maxTimeStr);
		if(currentTimeInt > maxTimeInt){
			maxTimeInt =currentTimeInt+60;
		}

		this.totalTime = maxTimeInt;
		
		if(currentTimeInt != this.currentTimeInt){
			this.currentTimeInt = currentTimeInt;
			var playWidth =parseInt( this.PROGRESS_MAX_WIDTH  * (currentTimeInt / maxTimeInt) -2);
			
	       	this.progressPast.setWidth(playWidth);
			this.progessLoaded.setWidth(parseInt(parseInt(ratio * this.PROGRESS_MAX_WIDTH) - playWidth-2));
			
			var width = J.viewport.getSize().width -10;
			var playWidth =parseInt( width  * (currentTimeInt / maxTimeInt));
			
			this.progressBarPast.setWidth(playWidth);
			this.progessBarLoaded.setWidth(parseInt(parseInt(ratio * width) - playWidth -2));
		}
        
    },
    createSimilarZone: function(zone){
        zone.update('');
        
        this.IconStatusChange = 'end';
        
        this.iconSimilar = zone.createChild({
            id: "similar-icon",
            cls: "similar-icon"
        });
        
        this.iconSimilarStart = zone.createChild({
            id: "similar-icon-start",
            cls: "similar-icon",
            style: "display:none",
            html: "<img src=\"/res/img/anim_start.gif\" />"
        });
        this.iconSimilarPlay = zone.createChild({
            id: "similar-icon-play",
            cls: "similar-icon",
            style: "display:none",
            html: "<img src=\"/res/img/anim_play.gif\" />"
        });
        this.iconSimilarEnd = zone.createChild({
            id: "similar-icon-end",
            cls: "similar-icon",
            style: "display:none",
            html: "<img src=\"/res/img/anim_end.gif\" />"
        });
        
        this.titleSimilar = zone.createChild({
            id: "similar-header"
        });
        
        this.titleSimilar.update(tr('suggestions_ifYouLike'));
        
        this.contentSimilar = zone.createChild({
            id: "similar-content"
        });
        
		this.createSimilarTrackZone();
    },
    
    createSimilarTrackZone: function(){
        this.contentSimilar.update("");
        
        this.caseRadio = this.contentSimilar.createChild({
            style: "overflow:hidden;height:55px;width:185px;"
        });
        this.caseUser = this.contentSimilar.createChild({
            style: "overflow:hidden;height:45px;width:185px;"
        });
        this.casePlaylist = this.contentSimilar.createChild({
            style: "overflow:hidden;height:45px;width:185px;"
        });
        this.caseTrack = this.contentSimilar.createChild({
            style: "overflow:hidden;height:55px;width:185px;"
        });
        
        this.caseRadio.on('click', function(){
            this.jwLaunchSimiliRadio(0);
        }, this.controller);
        this.caseRadio.update('<div id="similar-radio"><div class="header">' + tr("suggestions_similiRadio") + '</div><div class="teaser">' + tr("player-lunchSmartRadio") + '</div></div>');
        this.showSimilarTrack(0, true);
        
    },
    
    initSimilar: function(){
        zone = Ext.get('zone-socialMenu');
        if (zone) {
            this.createSimilarZone(zone);
        }
        
    },
    showSimilarTrack: function(index, first){
    
        var aDataSuggestionPage = this.controller.model.suggestions.page;
        
        if (aDataSuggestionPage && aDataSuggestionPage.length > 0) {
        
            if (index == aDataSuggestionPage.length) {
                index = 0;
            };
            
            var track = aDataSuggestionPage[index];
            
            if (!track) {
                return false;
            }
            if (first) {
                var time = 0;
            }
            else {
                var time = 10;
            }
            this.caseUser.pause(time).slideOut('r', {
                duration: 1,
                scope: this,
                
                callback: function(el){
                    this.caseUser.update('<div class="header">' + tr("discover_user") + '</div><div id="similar-user"><a href="#user/' + track.userId + '" >' + J.render.reduce(track.userName, 30) + '</a></div></div>');
                    this.caseUser.slideIn('l', {
                        duration: 1,
                        scope: this,
                        
                        callback: function(el){
                            this.casePlaylist.slideOut('r', {
                                duration: 1,
                                scope: this,
                                
                                callback: function(el){
                                    this.casePlaylist.update('<div class="header">' + tr("discover_playlist") + '</div><div id="similar-playlist"><a href="#playlist/' + track.playlistId + '" >' + J.render.reduce(track.playlistName, 30) + '</a></div></div>');
                                    this.casePlaylist.slideIn('l', {
                                        duration: 1,
                                        scope: this,
                                        
                                        callback: function(el){
                                            this.caseTrack.slideOut('r', {
                                                duration: 1,
                                                scope: this,
                                                callback: function(el){
                                                    this.caseTrack.update('<div class="header">' + tr("discover_track") + '</div><div id="similar-track"><a href="#track/' + track.trackId + '/play" ><span id="playerView-songName">' + J.render.reduce(track.songName, 30) + '</span><br/>' + J.render.reduce(track.artistName, 30) + '</a></div></div>');
                                                    this.caseTrack.slideIn('l', {
                                                        duration: 1,
                                                        scope: this,
                                                        
                                                        callback: function(el){
                                                            this.showSimilarTrack(index + 1, false);
                                                        }
                                                    })
                                                }
                                            })
                                        }
                                    })
                                }
                            })
                        }
                    })
                }
            })
        }
    },
    refreshMode: function(){
    
        if (this.mode != this.controller.mode) {
        
            if (this.controller.mode == 'RADIO') {
                this.radio = true;
                this.zone.addClass('radio');
                this.prevButton.disable();
                this.prevBottomButton.disable();
                this.nextButton.disable();
                this.nextBottomButton.disable();
                this.queueGrid.setHeight(105);
                this.shuffleButton.disable();
                this.repeatButton.disable();
                
            }
            else 
                if (this.controller.mode == 'INTERACTIVE_RADIO') {
                    this.radio = true;
                    this.zone.addClass('radio');
                    this.prevButton.disable();
                    this.prevBottomButton.disable();
                    this.nextButton.enable();
                    this.nextBottomButton.enable();
                    this.queueGrid.setHeight(105);
                    this.shuffleButton.disable();
                    this.repeatButton.disable();
                    
                }
                else {
                    this.radio = false;
                    this.radioIcon.update("");
                    this.radioName.update("");
                    this.zone.removeClass('radio');
                    this.queueGrid.setHeight(151);
                    this.prevButton.enable();
                    this.prevBottomButton.enable();
                    this.nextButton.enable();
                    this.nextBottomButton.enable();
                    this.shuffleButton.enable();
                    this.repeatButton.enable();
                }
            
            this.mode= this.controller.mode;
            
        }
        
        
    },
	selectTrack:function(index){
		this.queueGrid.getSelectionModel().unlock();
	    this.queueGrid.getSelectionModel().selectRow(index);
		this.queueGrid.getView().focusCell(index);
	    this.queueGrid.getSelectionModel().lock();
	},
    // private    
    loadTrack: function(track,index, preview){
        this.currentTrack = track;
        this.albumCover.update('<img src="' + J.MEDIAPATH + '/album/80/' + track.albumId + '.jpg" width="80" height="80"/>');
        var artisteName = Ext.util.Format.ellipsis(track.artistName, 45);
        this.currentArtist.update(artisteName);
        var songName = Ext.util.Format.ellipsis(track.songName, 45);
        this.currentSong.update(songName);
        this.currentBottomArtist.update(track.artistName);
        this.currentBottomSong.update(track.songName);
        this.setPlayMode(true);
        if (!preview) {
            this.timeCurrent.update("");
            this.timeTotal.update("loading...");
			J.fc.setTitle(track.artistName+' - '+track.songName);
        }
    },
    playTrack: function(track,index){
        this.currentTrack = track;
        J.fc.setTitle(track.songName + " -  " + track.artistName);
        this.albumCover.update('<img src="' + J.MEDIAPATH + '/album/80/' + track.albumId + '.jpg" width="80" height="80"/>');
        var artisteName = Ext.util.Format.ellipsis(track.artistName, 45);
        this.currentArtist.update(artisteName);
        var songName = Ext.util.Format.ellipsis(track.songName, 45);
        this.currentSong.update(songName);
        this.currentBottomArtist.update(track.artistName);
        this.currentBottomSong.update(track.songName);
        this.setPlayMode(true);
		J.fc.setTitle(track.artistName+' - '+track.songName);
    },
    
    setPlayMode: function(playMode){
     

            this.timeCurrent.update("");
            this.timeTotal.update("");
            this.albumCover.dom.style.background = "transparent";
     
        
    },
    setPaused: function(paused){
        x = this;
        if (paused) {
            if (x.IconStatusChange == 'play') {
                if (x.iconSimilarStart) {
                    setTimeout(function(){
                        x.iconSimilarPlay.dom.style.display = "none";
                        x.iconSimilarEnd.dom.style.display = "block";
                        x.IconStatusChange = 'stop';
                        setTimeout(function(){
                            if (x.IconStatusChange == 'stop') {
                                x.iconSimilarEnd.dom.style.display = "none";
                                x.iconSimilar.dom.style.display = "block";
                                x.IconStatusChange = 'end';
                            }
                        }, 300);
                    }, 100);
                };
                            };
            this.paused = true;
            this.playButton.show();
            this.playBottom.show();
            this.pauseButton.hide();
            this.pauseBottom.hide();
        }
        else {
            if (x.IconStatusChange == 'end') {
                if (x.iconSimilarStart) {
                    setTimeout(function(){
                        x.iconSimilar.dom.style.display = "none";
                        x.iconSimilarStart.dom.style.display = "block";
                        x.IconStatusChange = 'activate';
                        setTimeout(function(){
                            if (x.IconStatusChange == 'activate') {
                                x.iconSimilarStart.dom.style.display = "none";
                                x.iconSimilarPlay.dom.style.display = "block";
                                x.IconStatusChange = 'play';
                            }
                        }, 500);
                    }, 1000);
                }
            }
            this.paused = false;
            this.playButton.hide();
            this.playBottom.hide();
            this.pauseButton.show();
            this.pauseBottom.show();
            
        }
    },
    
    setVolume: function(volume){
        this.volumeBottom.setValue(volume);
        this.volume.setValue(volume);
        
    },
    albumClickHandler: function(){
        if (this.currentTrack) {
            J.fc.gotoUrl('album', this.currentTrack.albumId);
        }
    },
    artistClickHandler: function(){
        if (this.currentTrack) {
            J.fc.gotoUrl("artist", this.currentTrack.artistId);
        }
    },
    trackClickHandler: function(){
        if (this.currentTrack) {
            J.fc.gotoUrl("track", this.currentTrack.trackId);
        }
    },
    render: function(){
        
		this.zone.createChild({
            id: "jwPlayer"
        });
        
        this.player = this.zone.createChild({
            id: "player-bg"
        });
        
        this.albumCover = this.player.createChild({
            cls: "player-albumCover"
        });
        this.albumCover.on("click", this.albumClickHandler, this);
        
       this.progress = this.player.createChild({
			id : 'player-progress',
            html: '<div  id="player-inner-progress"  ><div id="player-progress-past"></div><div id="player-progress-current"></div><div id="player-progress-future"></div></div>'
        })
		
		this.progressBar = Ext.get("player-bar-progress");
        
		
		this.progressCurrent =  Ext.get("player-progress-current");
		this.progressPast =  Ext.get("player-progress-past");
		this.progessLoaded = Ext.get("player-progress-future");
		
		this.progressBarCurrent =  Ext.get("player-bar-progress-current");
		this.progressBarPast =  Ext.get("player-bar-progress-past");
		this.progessBarLoaded = Ext.get("player-bar-progress-future");
		
		
        this.tooltip = new Ext.ToolTip({
            target: this.progress,
            title: '00:00',
            showDelay: 0,
            listeners: {
                scope: this,
                move: function(title, x, y){
                    var left = this.progress.getLeft()+ 15 ;
                    var time = this.timePositionToStr((x - left),true);
                    title.setTitle(time);
                }
            },
            trackMouse: true
        });
        
        
		this.tooltip = new Ext.ToolTip({
            target: this.progressBar,
            title: '00:00',
            showDelay: 0,
            listeners: {
                scope: this,
                move: function(title, x, y){
					 var left = this.progress.getLeft()- 220;
                    var time = this.timeBarPositionToStr(x-left,true);
                    title.setTitle(time);
                }
            },
            trackMouse: true
        });
		
        this.progress.on('click', function(event, element){
            if (!this.radio) {
                this.controller.progressClickHandler(this.selectedTime );
            }
        }, this);
		
		this.progressBar.on('click', function(event, element){
            if (!this.radio) {
                this.controller.progressClickHandler(this.selectedTime );
            }
        }, this);
        
        this.timeCursor = this.player.createChild({
            cls: "player-time-cursor"
        });
        
        this.timeCurrent = this.player.createChild({
            cls: "player-time-current"
        });
        this.timeTotal = this.player.createChild({
            cls: "player-time-total"
        });
        
        this.volume = new Ext.ButtonVolume({
            tooltip: tr("player-volume"),
            renderTo: this.player.createChild({
                cls: "player-volume"
            }),
            handler: function(button, value){
                this.controller.jwSetVolume(value);
            },
            scope: this
        });
        
        this.volumeIcon = new Ext.SimpleButton({
            tooltip: tr("player-volumeIcon"),
            renderTo: this.player.createChild({
                cls: "player-volumeIcon"
            }),
            handler: function(){
                this.mute();
            },
            scope: this.controller
        });
        
        this.prevButton = new Ext.SimpleButton({
            tooltip: tr("player-prev"),
            renderTo: this.player.createChild({
                cls: "player-prev"
            }),
            handler: function(){
                this.jwPrevious();
            },
            scope: this.controller
        });
        
        
        
        this.playButton = new Ext.SimpleButton({
            tooltip: tr("player-play"),
            renderTo: this.player.createChild({
                cls: "player-play"
            }),
            handler: function(){
                this.jwResume();
            },
            scope: this.controller
        });
        
        
        this.pauseButton = new Ext.SimpleButton({
            tooltip: tr("player-pause"),
            renderTo: this.player.createChild({
                cls: "player-pause"
            }),
            handler: function(){
                this.jwPause();
            },
            hidden: true,
            scope: this.controller
        });
		
		  this.playButton = new Ext.SimpleButton({
            tooltip: tr("player-play"),
            renderTo: this.player.createChild({
                cls: "player-play"
            }),
            handler: function(){
                this.jwResume();
            },
            scope: this.controller
        });
        
        
        this.pauseButton = new Ext.SimpleButton({
            tooltip: tr("player-pause"),
            renderTo: this.player.createChild({
                cls: "player-pause"
            }),
            handler: function(){
                this.jwPause();
            },
            hidden: true,
            scope: this.controller
        });
        
        
        
        this.nextButton = new Ext.SimpleButton({
            tooltip: tr("player-next"),
            renderTo: this.player.createChild({
                cls: "player-next"
            }),
            handler: function(){
                this.jwNext();
            },
            scope: this.controller
        });
        
		this.prevBottomButton = new Ext.SimpleButton({
            cls: "player-bar-prev",
            handler: function(){
                this.jwPrevious();
            },
            scope: this.controller
        });
        
        
        this.playBottom = new Ext.SimpleButton({
            cls: "player-bar-play",
            handler: function(){
                this.jwResume();
            },
            scope: this.controller
        });
        
        
        this.pauseBottom = new Ext.SimpleButton({
            cls: "player-bar-pause",
            handler: function(){
                this.jwPause();
            },
            hidden: true,
            scope: this.controller
        });
        
        this.nextBottomButton = new Ext.SimpleButton({
            cls: "player-bar-next",
            handler: function(){
                this.jwNext();
            },
            scope: this.controller
        });
        
        
        
        this.volumeIconBottom = new Ext.SimpleButton({
            cls: "player-bar-volumeIcon",
            handler: function(){
                this.mute();
            },
            scope: this.controller
        });
        
        this.volumeBottom = new Ext.ButtonVolume({
            cls: "player-bar-volume",
            handler: function(button, value){
                this.controller.jwSetVolume(value);
            },
            scope: this
        });
        
        
        this.onAirBottom = new Ext.SimpleButton({
            cls: "player-bar-volume",
            handler: function(button, value){
                this.controller.jwSetVolume(value);
            },
            scope: this
        });
      
	  
	    this.playerBar.left = true;
        
        this.playerBar.addDom({
            id: 'player-logo'
        });
        
        this.playerBar.addSeparator();
        
        this.playerBar.addItem(this.prevBottomButton);
        this.playerBar.addItem(this.playBottom);
        this.playerBar.addItem(this.pauseBottom);
        this.playerBar.addItem(this.nextBottomButton);
        
        this.playerBar.addSeparator();
        this.playerBar.addItem(this.volumeIconBottom);
        this.playerBar.addItem(this.volumeBottom);
        
        this.playerBar.addSeparator();
        
        this.playerBarInfo  = this.playerBar.addDom({
            id: 'player-bar-info'
        });
    
        this.playerBar.info = Ext.get('player-bar-info');
        
        this.currentBottomArtist = this.playerBar.info.createChild({
            cls: "player-button"
        });
        this.currentBottomArtist.on("click", this.artistClickHandler, this);
        
        this.currentBottomSong = this.playerBar.info.createChild({
            cls: "player-currentSong"
        });
        this.currentBottomSong.on("click", this.trackClickHandler, this);
   
        this.playerBar.left = false;
        
        
        this.shuffleButton = new Ext.SimpleButton({
            enableToggle: true,
            renderTo: this.player.createChild({
                cls: "player-shuffle"
            }),
            toggleHandler: function(button, state){
                this.jwToggleShuffleMode(state);
            },
            scope: this.controller
        });
        
        this.repeatButton = new Ext.SimpleButton({
            tooltip: tr("player-repeat"),
            enableToggle: true,
            renderTo: this.player.createChild({
                cls: "player-repeat"
            }),
            toggleHandler: function(button, state){
                this.jwToggleRepeatMode(state);
            },
            scope: this.controller
        });
		
		
		   this.restrictedButton = new Ext.SimpleButton({
            tooltip: tr("player-restricted"),
            enableToggle: true,
            renderTo: this.player.createChild({
                cls: "player-restricted"
            }),
            toggleHandler: function(button, state){
                this.jwToggleRestrictedMode(state);
            },
            scope: this.controller
        });
        
        this.similiButton = new Ext.SimpleButton({
            tooltip: tr("player-simili"),
            renderTo: this.player.createChild({
                cls: "player-simili"
            }),
            handler: function(){
                this.jwLaunchSimiliRadio(0);
            },
            scope: this.controller
        });
        
        // Right part
        this.currentArtist = this.player.createChild({
            cls: "player-currentArtist"
        });
        this.currentArtist.on("click", this.artistClickHandler, this);
        
        this.currentSong = this.player.createChild({
            cls: "player-currentSong"
        });
        this.currentSong.on("click", this.trackClickHandler, this);
        
        
        //text Bar 
        this.radioIcon = this.player.createChild({
            id: "player-radio"
        });
        
        this.radioName = this.player.createChild({
            id: "player-radioName"
        });
        
        this.subscribeButton = new Ext.SimpleButton({
            tooltip: tr("player-subscribeRadio"),
            renderTo: this.player.createChild({
                cls: "player-subscribeRadio"
            }),
            handler: this.controller.subscribe,
            scope: this
        });
        
        this.unsubscribeButton = new Ext.SimpleButton({
            tooltip: tr("player-unsubscribeRadio"),
            renderTo: this.player.createChild({
                cls: "player-unsubscribeRadio"
            }),
            handler: this.controller.unsubscribe,
            scope: this
        });
        
        
        this.addCurrentTrack = new Ext.SimpleButton({
            tooltip: tr("addToPlaylist"),
            renderTo: this.player.createChild({
                cls: "player-addCurrent"
            }),
            handler: function(){
            
                record = [{
                    data: this.currentTrack
                }];
                J.fc.getController("playlistAdder", true).show({
                    records: record
                });
            },
            scope: this.controller
        });
        
        
        this.suggestCurrentTrack = new Ext.SimpleButton({
            tooltip: tr("suggestion_popup_header"),
            renderTo: this.player.createChild({
                cls: "player-suggestCurrent"
            }),
            handler: function(){
            
                J.fc.getController("track", true).suggest(this.currentTrack);
            },
            scope: this.controller
        });
        
        
        var buttons = this.player.createChild({
            cls: "player-trackButtons"
        });
        
        this.permalinkCurrentTrack = new Ext.DivButton({
            text: tr("link"),
            renderTo: buttons.createChild({
                cls: "player-trackButton player-permalink"
            }),
            handler: function(){
            
                this.permalink();
            },
            scope: this.controller
        });
		
		   this.widgetCurrentTrack = new Ext.DivButton({
            text: tr("share"),
            renderTo: buttons.createChild({
                cls: "player-trackButton player-widget"
            }),
            handler: function(){
        
                this.share();
            },
            scope: this.controller
        });
       
	 /*   this.PubTrack = new Ext.Button({
            text: "ADWS",
            renderTo: buttons.createChild({
                cls: "player-trackButton player-widget"
            }),
            handler: function(){
            this.jwPlayAd();
            },
            scope: this.controller
        });
		
	*/	
        this.downloadCurrentTrack = new Ext.DivButton({
            disabled: true,
            text: tr("player-download"),
            renderTo: buttons.createChild({
                cls: "player-trackButton player-dowload"
            }),
            handler: function(){
            
                this.download();
            },
            scope: this.controller
        });
        this.addAllToPlaylist = new Ext.SimpleButton({
            tooltip: tr("player-addAll"),
            renderTo: this.player.createChild({
                cls: "player-addAll"
            }),
            handler: function(){
                J.fc.getController("playlistAdder", true).addAlltracksOfGrid(this.queueGrid);
            },
            scope: this
        });
        
        this.clearQueue = new Ext.SimpleButton({
            tooltip: tr("player-clearQueue"),
            renderTo: this.player.createChild({
                cls: "player-clearQueue"
            }),
            handler: function(){
                this.jwClearQueue();
            },
            scope: this.controller
        });
        this.queueWrapper = this.player.createChild({
            id: "player-queueWrapper"
        });
        
        var controller = this.controller;
        this.queueGrid = new Ext.grid.GridPanel({
            store: this.model.store,
            columns: [{
                id: 'songName',
                sortable: false,
                dataIndex: 'songName',
                width: 225,
                renderer: this.songNameRenderer
            }, {
                id: 'info',
                dataIndex: 'trackId',
                width: 14,
                sortable: false,
                renderer: this.infoButtonRenderer
            }, {
                id: 'add',
                dataIndex: 'songId',
                width: 20,
                sortable: false,
                renderer: this.addButtonRenderer
            }, {
                id: 'delete',
                dataIndex: 'artistId',
                width: 25,
                sortable: false,
                renderer: this.deleteButtonRenderer
            }],
            
            width: 293,
            autoHeight: false,
            autoScroll: true,
            height: 151,
            frame: false,
            enableDragDrop: true,
            stripeRows: true,
            hideHeaders: true,
            iconCls: 'icon-grid',
            ddText: tr('repos_this_title'),
            renderTo: this.queueWrapper,
            listeners: {
                render: function(g){
                    var ddrow = new Ext.ux.dd.GridReorderDropTarget(g, {
                        copy: false
                    });
                    
                    Ext.dd.ScrollManager.register(g.getView().getEditorParent());
                },
                beforedestroy: function(g){
                    Ext.dd.ScrollManager.unregister(g.getView().getEditorParent());
                }
                
                
            }
        
        });
		
		
        this.queueGrid.getSelectionModel().lock();
        this.queueGrid.on("cellclick", function(grid, rowIndex, columnIndex, e){
        
            var record = grid.getStore().getAt(rowIndex);
            var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
            
			
        if (record.data.songId > 0) {
		
			if (fieldName == 'songName' & !this.radio) {
				this.controller.jwPlayTrackAtIndex(record.data, rowIndex);
			}
			else 
				if (fieldName == 'artistId' & !this.radio) {
					this.controller.jwRemoveTracks(rowIndex, 1);
					
				}
				else 
					if (fieldName == 'songId') {
						J.fc.getController("playlistAdder", true).show({
							records: [record]
						});
					}
					else {
						
							J.fc.gotoUrl('track', record.data.trackId);
							
					}
			
		}
            
            
        }, this);
        
        /* Flash */
        var flashvars = {
			"debug": "console.log",
            "engineReadyHandler": "jwPlayer.engineReadyHandler",
            "engineQueueAddHandler": "jwPlayer.engineQueueAddHandler",
            "engineClearQueueHandler": "jwPlayer.engineClearQueueHandler",
            "engineEndQueueHandler": "jwPlayer.engineEndQueueHandler",
            "engineQueueMoveHandler": "jwPlayer.engineQueueMoveHandler",
            "engineRemoveTracksHandler": "jwPlayer.engineRemoveTracksHandler",
            "engineLoadingTrackHandler": "jwPlayer.engineLoadingTrackHandler",
            "enginePlayTrackHandler": "jwPlayer.enginePlayTrackHandler",
            "enginePauseTrackHandler": "jwPlayer.enginePauseTrackHandler",
            "engineResumeTrackHandler": "jwPlayer.engineResumeTrackHandler",
			"engineCompletePlayHandler": "jwPlayer.engineCompletePlayHandler",
            "engineProgressHandler": "jwPlayer.engineProgressHandler",
            "engineLoadProgressHandler": "jwPlayer.engineLoadProgressHandler",
			"getMode": "jwPlayer.jwGetMode"
        };
        
        var params = {
            wmode: "opaque",
            id: "jwPlayer",
            allowscriptaccess: "always"
        };
        
        var attributes = {};
        var currentTime = new Date();
        var t = currentTime.getTime();
        path = "/res/widget/LightPlayer.swf?=" + t;
        
        swfobject.embedSWF(path, "jwPlayer", "1", "1", "9.0.0", "/res/swf/expressinstall.swf", flashvars, params, attributes);
        
        this.setPlayMode(false);
        
        this.initSimilar();
    },
    
    songNameRenderer: function(value, meta, record){
    
        if (record.data.songId > 0) {
        
            if (Ext.isIE) {
                var defaultSize = 15;
                var maxSize = 30;
            }
            else {
                var defaultSize = 15
                var maxSize = 40;
            }
            
            var total = record.data.artistName.length + record.data.songName.length;
            
            
            if (total <= maxSize) {
            
                return String.format('<span class="player-queue-playing"></span><span class="player-queue-songName">{1}</span><span class="player-queue-artistName">{0}</span>', record.data.artistName, record.data.songName);
                
                
            }
            else 
                if ((total - record.data.artistName.length + (defaultSize + 3)) <= maxSize) {
                
                    var max = maxSize - record.data.songName.length;
                    
                    return String.format('<span class="player-queue-playing"></span><span class="player-queue-songName">{1}</span><span class="player-queue-artistName">{0}</span>', J.render.reduce(record.data.artistName, max), record.data.songName);
                    
                    
                }
                else 
                    if ((total - record.data.songName.length + (defaultSize + 3)) <= maxSize) {
                    
                        var max = maxSize - record.data.artistName.length;
                        
                        return String.format('<span class="player-queue-playing"></span><span class="player-queue-songName">{1}</span><span class="player-queue-artistName">{0}</span>', record.data.artistName, J.render.reduce(record.data.songName, max));
                        
                    }
                    else {
                    
                        return String.format('<span class="player-queue-playing"></span><span class="player-queue-songName">{1}</span><span class="player-queue-artistName">{0}</span>', J.render.reduce(record.data.artistName, defaultSize), J.render.reduce(record.data.songName, defaultSize));
                        
                        
                    }
            
        }
        
        return value;
    },
    
    addButtonRenderer: function(value){
        if (value > 0) {
            return "<div class='icon'></div>";
        }
        return "";
    },
    refreshAction: function(){
    
    
        if (this.controller.isFan()) {
            this.showUnSubscribe();
            
        }
        else {
            this.showSubscribe();
        }
        
    },
    showSubscribe: function(){
    
        this.subscribeButton.show();
        this.unsubscribeButton.hide();
        
    },
    showUnSubscribe: function(){
    
        this.subscribeButton.hide();
        this.unsubscribeButton.show();
        
    },
    infoButtonRenderer: function(value){
        if (value > 0) {
            return "<a href='#track/" + value + "'><div class='icon'></div></a>";
        }
        return "";
    },
    deleteButtonRenderer: function(value){
        if (value > 0) {
            return "<div class='icon'></div>";
        }
        return "";
    },
    timePositionToStr: function(ratio,setTime){
        var s = "";
        var x = parseInt(this.totalTime * (ratio /this.PROGRESS_MAX_WIDTH ) );
        
		if(setTime){
			this.selectedTime =x;
		}
		
        var mins = parseInt(x / 60);
        var secs = parseInt(x - mins * 60);
        
  
        if (mins < 10) {
            s = '0';
        }
        s = mins + ':';
        if (secs < 10) {
            s += '0';
        }
        
        s += secs;
        return s;
    },
	  timeBarPositionToStr: function(ratio,setTime){
        var s = "";
		var width = J.viewport.getSize().width -10;
        var x = parseInt(this.totalTime * (ratio /width) );
        
		if(setTime){
			this.selectedTime =x;
		}
		
        var mins = parseInt(x / 60);
        var secs = parseInt(x - mins * 60);
        
  
        if (mins < 10) {
            s = '0';
        }
        s = mins + ':';
        if (secs < 10) {
            s += '0';
        }
        
        s += secs;
        return s;
    }
    
});
J.View.Search = function(options) {
    J.View.Search.superclass.constructor.call(this,options);
    this.type = options.type;
    this.zone = J.fc.getZone("searchbar");
    this.domain = null;
};

Ext.extend(J.View.Search, J.View.Base, {
	
    render: function() {
        this.domain = "track";
		
		this.store = new Ext.data.SimpleStore({
		        fields: ['artist'],
		        data : VariousArtists
		    });
	
		var xxx=this;		

		this.field = new Ext.app.SearchField({
				typeAhead: true,
				scope:this,
				store: this.store,
				domain: this.domain,
		        mode: 'local',
		        triggerAction: 'all',
				width :	480,	
		        emptyText:tr('search_track_title'),
				displayField:'artist',				
				name:'search',
				id:'search-header-input',
				handler: function(){
					xxx.onSimpleSubmit();
				}
			});
		
		this.butDomain = new Ext.Button({
				width: 120,
	            text: tr('searchBar_domain_track'),
	            menu : {cls:'search-menu', items: [
	                        {domain:'track', text: tr('searchBar_domain_track'),scope:this,handler: this.onChangeDomain},
							{domain:'album', text: tr('searchBar_domain_album'), scope:this,handler: this.onChangeDomain},
							{domain:'artist', text: tr('searchBar_domain_artist'), scope:this,handler: this.onChangeDomain},
	                        {domain:'user', text: tr('searchBar_domain_user'), scope:this, handler: this.onChangeDomain},//, handler: onItemClick
	                        {domain:'playlist', text: tr('searchBar_domain_playlist'), scope:this,handler: this.onChangeDomain}
	            ]}
	        });
		
			this.butAdvanced = new Ext.Button({
				width:14,
				cls:'plus',
				enableToggle: true
			});
			this.butAdvanced.on('toggle', this.onAdvancedToggle, this);
			

		this.simpleForm = new Ext.FormPanel({
		    layout:'column',
			scope:this,
			renderTo :this.zone,
			submit: this.onSimpleSubmit,
				keys : [ {
			key :13,
			fn :this.onSimpleSubmit,
			scope :this
				} ],
			border:false,
		    items: [{
					border:false,
				 cls: "search-logo",
				 id: "main-button-search"
				 
			},{
				width :6,
				border:false,
				 cls: "field-start"
			},{
		  	width: 520,
			  border:false,
			  cls:'field-middle search-wrapper',
			  items :this.field
		    },{
				width :6,
				border:false,
				 cls: "field-end"
			},{
				width :6,
				border:false,
				 cls: "field-start"
			},{
		     width: 120,
			  border:false,
			   cls:'field-middle search-domain',
			 items :this.butDomain
		    },{
				width :6,
				border:false,
				 cls: "field-end"
			},{
				width :6,
				border:false,
				 cls: "field-start"
			},{
		     width: 18,
			  border:false,
			   cls:'field-middle search-toogle-advanced',
			items :this.butAdvanced
		    },{
				width :6,
				border:false,
				 cls: "field-end"
			}]
		});
		
		Ext.get('main-button-search').on('click', function(){
			this.onSimpleSubmit();
		},this);
			
		this.input = Ext.get('search-header-input');
		
		this.advanced = Ext.get('zone-search-advanced');
		
		
		var width = this.input.getWidth();
		
		this.input.setWidth(width-20);
		
		if(!this.domain) {
				this.setDomainTrack();
		}

	},
	// ========================================================================
		onAdvancedToggle: function(b, pressed) {
			this.setAdvancedMode(pressed);
		},
		// ========================================================================
		onAdvancedClose: function() {
			this.setAdvancedMode(false);
		},
		// ========================================================================
		onAdvancedSubmit : function(){
			if(this.advancedMode) {
				var p = this.formPanel.form.getValues();
			} else {
				var p = {q: this.input.getValue()};
			}
			J.fc.gotoUrl("search", this.domain, p);
			return false;
		},
		onSimpleSubmit: function() {
				var p = { q: Ext.get('search-header-input').getValue().replace(/[-\/]/g, " ")};
				
					J.fc.gotoUrl("search", this.domain, p);
				
		},
		// ========================================================================
		setDomainTrack: function() {
			if(this.domain == 'track' && (this.formPanel ? this.advancedMode : !this.advancedMode)) {
				return;
			}
			this.domain = 'track';
			var value =this.input.getValue();
			if (value == tr('search_jiwer_email') ||value ==tr('search_playlist_tag') ||value ==tr('search_track_title') ||value ==tr('search_artist_title') ||value ==tr('search_album_title') || value == '' ) {
				this.field.setEmptyText(tr('search_track_title'));
				this.field.applyEmptyText();
							
			}
		
		
		
			this.butDomain.setText(tr('searchBar_domain_track'));
			if(this.advancedMode) {
				var body = this.realAdvancedBody;
				body.update('');

				this.formPanel = new Ext.form.FormPanel({
					bodyStyle: 'padding: 15px',
			        labelWidth: 200,
					renderTo: body,
			        frame: false,
			        defaults: {width: 350},
					autoHeight: true,
			        items: 
					[
						new Ext.form.Hidden({
							name: 'domain',
							value: 'track'
						}),
						new Ext.form.TextField({
							type: 'text',
							fieldLabel: tr('searchBar_music_artist'),
							name: 'artistName'
							}),
						new Ext.form.TextField({
							type: 'text',
							fieldLabel: tr('searchBar_music_album'),
							name: 'albumName'
							}),
						new Ext.form.TextField({
							type: 'text',
							fieldLabel: tr('searchBar_music_song'),
							name: 'songName'
							})
					]
				});
			}
			
		},
		setDomainArtist: function() {
			if(this.domain == 'artist' && (this.formPanel ? this.advancedMode : !this.advancedMode)) {
				return;
			}
			this.domain = 'artist';
			var value =this.input.getValue();
			if (value == tr('search_jiwer_email') ||value ==tr('search_playlist_tag') ||value ==tr('search_track_title') ||value ==tr('search_album_title') || value == '' ) {
				this.field.setEmptyText(tr('search_artist_title'));	
				this.field.applyEmptyText();
						
			}
		
			this.butDomain.setText(tr('searchBar_domain_artist'));
			if(this.advancedMode) {
				var body = this.realAdvancedBody;
				body.update('');

				this.formPanel = new Ext.form.FormPanel({
					bodyStyle: 'padding: 15px',
			        labelWidth: 200,
					renderTo: body,
			        frame: false,
			        defaults: {width: 350},
					autoHeight: true,
			        items: 
					[
						new Ext.form.Hidden({
							name: 'domain',
							value: 'artist'
						})
					]
				});
			}
			
		},
		setDomainAlbum: function() {
			if(this.domain == 'album' && (this.formPanel ? this.advancedMode : !this.advancedMode)) {
				return;
			}
			this.domain = 'album';
			var value =this.input.getValue();
			if (value == tr('search_jiwer_email') ||value ==tr('search_playlist_tag')||value ==tr('search_artist_title') ||value ==tr('search_album_title')  || value == '' ) {
				this.field.setEmptyText(tr('search_album_title'));	
				this.field.applyEmptyText();
			}
		
			this.butDomain.setText(tr('searchBar_domain_album'));
			if(this.advancedMode) {
				var body = this.realAdvancedBody;
				body.update('');

				this.formPanel = new Ext.form.FormPanel({
					bodyStyle: 'padding: 15px',
			        labelWidth: 200,
					renderTo: body,
			        frame: false,
			        defaults: {width: 350},
					autoHeight: true,
			        items: 
					[
						new Ext.form.Hidden({
							name: 'domain',
							value: 'album'
						}),
						new Ext.form.TextField({
							type: 'text',
							fieldLabel: tr('searchBar_music_artist'),
							name: 'artistName'
						})
					]
				});
			}
			
			},
		// ========================================================================
		setDomainPlaylist: function() {
			if(this.domain == 'playlist' && (this.formPanel ? this.advancedMode : !this.advancedMode)) {
				return;
			}
			this.domain = 'playlist';
	

			var value =this.input.getValue();
			if (value == tr('search_jiwer_email') ||value ==tr('search_track_title') ||value ==tr('search_artist_title') ||value ==tr('search_album_title') || value == '' ) {
					this.field.setEmptyText(tr('search_playlist_tag'));
					this.field.applyEmptyText();
			
			}
			
			this.butDomain.setText(tr('searchBar_domain_playlist'));
			if(this.advancedMode) {
				var body = this.realAdvancedBody;
				body.update('');
				this.formPanel = new Ext.FormPanel({
					bodyStyle: 'padding: 15px',
			        labelWidth: 200,
					renderTo: body,
			        frame: false,
			        defaults: {width: 350},
					autoHeight: true,
			        items: 
					[
						new Ext.form.Hidden({
							name: 'domain',
							value: 'playlist'
						}),
						new Ext.form.TextField({
							type: 'text',
							fieldLabel: tr('searchBar_playlist_name'),
							name: 'playlistName'
							}),
						new Ext.form.TextArea({
							type: 'textArea',
							fieldLabel: tr('searchBar_playlist_tags'),
							style: 'height: 150px',
							name: 'tags',
							maxLength: '255'
						})
					]
				});
			}
		},
		// ========================================================================
		setDomainUser: function() {
			if(this.domain == 'user' && (this.formPanel ? this.advancedMode : !this.advancedMode)) {
				return;
			}
			this.domain = 'user';
			var value =this.input.getValue();
			if (value ==tr('search_playlist_tag') ||value ==tr('search_track_title') ||value ==tr('search_artist_title') ||value ==tr('search_album_title')  || value == '' ) {
			
			this.field.setEmptyText(tr('search_jiwer_email'));
			this.field.applyEmptyText();
			
			}
			this.butDomain.setText(tr('searchBar_domain_user'));
			if(this.advancedMode) {
				var body = this.realAdvancedBody;

				body.update('');
				this.formPanel = new Ext.FormPanel({
					bodyStyle: 'padding: 15px',
			        labelWidth: 200,
					renderTo: body,
			        frame: false,
			        defaults: {width: 350},
					autoHeight: true,
			        items: 
					[
					new Ext.form.Hidden({
						name: 'domain',
						value: 'user'
					}),
					new Ext.form.TextField({
						fieldLabel: tr('searchBar_user_name'),
						name: 'userName',
						maxLength: '16'
					}),
					new Ext.form.Checkbox({
						boxLabel: tr('searchBar_user_female'),
						name: 'sex-female',
						fieldLabel: 'Sexe',
						checked: true
					}),
					new Ext.form.Checkbox({
						boxLabel: tr('searchBar_user_male'),
						name: 'sex-male',
						fieldLabel: '&nbsp;',
						labelSeparator: null,
						checked: true
					}),

					new Ext.form.SelectField({
						data: arrTr('countries'),
						name: 'countryId',
						fieldLabel: tr('searchBar_user_country')
					}),
					
					new Ext.form.TextField({
						fieldLabel: tr('searchBar_user_town'),
						name: 'town'
					}),
				
					new Ext.form.NumberField({
						fieldLabel: tr('searchBar_user_minAge'),
						name: 'age-min',
						allowDecimals: false,
						allowNegative : false,
						maxValue: 90,
						minValue: 13
					}),
					new Ext.form.NumberField({
						fieldLabel: tr('searchBar_user_maxAge'),
						name: 'age-max',
						allowDecimals: false,
						allowNegative : false,
						maxValue: 90,
						minValue: 13
					}),

				
					new Ext.form.Checkbox({
						boxLabel: tr('searchBar_user_single'),
						name: 'relationship-single',
						fieldLabel: 'Relation',
						checked: true
					}),
				
				
					new Ext.form.Checkbox({
						boxLabel: tr('searchBar_user_couple'),
						name: 'relationship-couple',
						fieldLabel: '&nbsp;',
						labelSeparator: null,
						checked: true
					})
					
					
					]
				});
			}
		},
		// ========================================================================
		setAdvancedMode: function(advancedMode) {
			
			this.butAdvanced.toggle(advancedMode);
			
			if(advancedMode === this.advancedMode) {
				return;
			}
			this.advancedMode = advancedMode;
			//this.butAdvanced.setText(advancedMode? "-" : "+");

			if(advancedMode) {
						//this.headerSubmit.hide();
				this.advanced.show();
				this.advancedPanel = new Ext.Panel({
					renderTo: 'zone-search-advanced',
					id:'advanced-search',
					anchor:'100%',
					bodyStyle:'backgound-color:#ebebea',
					frame:true,
					buttons: [
						{text: tr('searchBar_button_search').bold(), handler: this.onAdvancedSubmit, scope: this},
						{text: tr('searchBar_button_close').italics(), handler: this.onAdvancedClose, scope: this}
					],
					keys: [
						{key: 13, fn: this.onAdvancedSubmit, scope: this}
					]
					
				});
				var body = this.advancedPanel.body;
				
				this.realAdvancedBody = body.createChild({cls: 'body'});
				
				if(this.domain == 'track') {
					this.setDomainTrack();
				} else if (this.domain == 'user') {
					this.setDomainUser();
				} else if (this.domain == 'playlist') {
					this.setDomainPlaylist();
				} else if (this.domain == 'album') {
					this.setDomainAlbum();
				} else if (this.domain == 'artist') {
					this.setDomainArtist();
				}

				if(this.advancedPanel) {
					this.advancedPanel.getEl().show();
				}

			} else {
				if(this.advancedPanel) {
					this.advancedPanel.getEl().slideOut('t', {duration: 0.2, remove: true});
					Ext.get('zone-search-advanced').update('');
					this.advanced.hide();
				}
				
				
				
				this.input.focus();
				
				this.formPanel = null;
			}
		},
		// ========================================================================
		setValue: function(v) {
			this.input.dom.value = v;
		}, 
	onChangeDomain: function(el, evt){
		if (el.domain == 'track') {
			this.setDomainTrack();
		}else if (el.domain == 'playlist') {
			this.setDomainPlaylist();
		}else if (el.domain == 'user') {
			this.setDomainUser();
		}else if (el.domain == 'album') {
			this.setDomainAlbum();
		}else if (el.domain == 'artist') {
			this.setDomainArtist();
		}
	}
});


J.View.Footer = Ext.extend( J.View.Base, {

	
	render: function() {
		this.zone = J.fc.getZone("footer");
		
		var panels = [];
		var colPanel;
		var colHtml;
		var first = true;
		
		
		var data = [{
        title:  tr('footer_col1_header'),
        items: [	{tag: 'a', href:"http://blog.jiwa.fm", text: tr('footer_blog'), target:'_blank'},
					{tag: 'a', href:"http://forum.jiwa.fm", text: tr('footer_forum'), target:'_blank'},
					{tag: 'a', href:"http://www.facebook.com/home.php#/pages/JIWA/54549603089?ref=nf", text: tr('footer_facebook'), target:'_blank'},
					{tag: 'a', href:"http://www.myspace.com/jiwamusic", text: tr('footer_myspace'), target:'_blank'},
					{tag: 'a', href:"http://twitter.com/Jiwa", text: 'Twitter', target:'_blank'}
					]
    }, {
        title: tr('footer_col2_header'),
        items: [	{tag: 'a', href: '#text/contact', text: tr('footer_contact')},
					{tag: 'a', href: '#text/press', text: tr('footer_press')},
					{tag: 'a', href: '#text/jobs', text: tr('footer_job')},
					{tag: 'a', href: '#text/legal', text: tr('footer_legal')},
					{tag: 'a', href: '#text/tou', text: tr('footer_tou')}
		]
			
    }, {
        title: tr('footer_col3_header'),
        items: [{tag: 'a', href: '#fr', lang: 'fr', text: tr('footer_lang_fr')},
				{tag: 'a', href: '#en', lang: 'en', text: tr('footer_lang_en')}]
    }, {
        title: tr('footer_col4_header'),
        items: [	{tag: 'a', href: '#text/faq', text: tr('footer_faq')},
					{tag: 'a', href:"http://forum.jiwa.fm", text: tr('footer_forum'), target:'_blank'},		
					{tag: 'a', href: '#text/dataPrivacy', text: tr('footer_dataPrivacy')},
					{tag: 'a', href: '#text/illicit', text: tr('footer_illicit')}]
    }];
	
	var nbCols = data.length;
		Ext.each(data, function(colData) {
			colHtml = "<ul>";
			Ext.each(colData.items, function(item) {
			
				item.target = item.target?" target='"+item.target+"'" :'';
				
				colHtml += "<li><a href ='"+
		item.href
				+"'"+
				item.target
				+" >" + item.text + "</a></li>"
			});
			colHtml += "</ul>";
			colPanel = {
				title: colData.title,
				html: colHtml,
				height:165,
				columnWidth: 1 / nbCols,
				border: false
			};
			if(first) {
				first = false;
				colPanel.cls = "x-column-first";
			}
			panels.push(colPanel);
		});
	
	this.panel=	new Ext.Panel({
			renderTo: this.zone,
			hideBorders:true,
			layout: "column",
			items: panels
		});
		

		
	}
});


J.View.PlaylistAdder = Ext.extend(J.View.Base, {

    /**
     * Render a list of news
     * @param {J.Model.News} news
     */
    win: null,
    render: function(){
    
        var PositionField = new Ext.form.RadioGroup({
            id: 'postition',
            width: 'auto',
            items: [{
                boxLabel: tr('at_start'),
                width: 80,
                id: 'start-radio',
                name: 'position',
                inputValue: 'begin',
                checked: true
            }, {
                boxLabel: tr('at_end'),
                width: 80,
                id: 'end-radio',
                name: 'position',
                inputValue: 'end'
            }]
        });


        var x=this;
 		this.selectionModel = new Ext.grid.CheckboxSelectionModel({singleSelect:true});
		this.selectionModel.width =30;
        
	   	this.playlistPanel = new Ext.grid.GridPanel({
	   		height: 250,
	   		hideHeaders: true,
	   		stripeRows: true,
	   		cls: 'playlistAdder',
	   		columns: [ {
	   			header: tr("folder"),
	   			dataIndex: 'playlistFolder',
	   			width: 10,
	   			renderer: function(value){
	   				return '<span class="folderName">' + value + '</span>';
	   			}
				},{
	   			header: "",
	   			dataIndex: 'playlistName',
	   			width: 200
	   		}, this.selectionModel],
	   		view: new Ext.grid.GroupingView({
	   			forceFit: true,
	   			groupTextTpl: '{text}',
				showGroupName : false
	   		}),
	   		store: J.me.playlistsStore,
	   		autoScroll: true,
	   		tpl: this.tpl,
	   		tbar: ['->',tr('search_playlist') + ':', {
	   			xtype: 'trigger',
	   			triggerClass: 'x-form-clear-trigger',
	   			onTriggerClick: function(){
	   				this.setValue('');
	   				J.me.playlistsStore.clearFilter();
	   			},
	   			id: 'filter',
	   			width: 280,
	   			enableKeyEvents: true,
	   			listeners: {
	   				keyup: {
	   					buffer: 150,
	   					fn: function(field, e){
	   						if (Ext.EventObject.ESC == e.getKey()) {
	   							field.onTriggerClick();
	   						}
	   						else {
	   							var val = this.getRawValue();
	   							var re = new RegExp('.*' + val + '.*', 'i');
	   							J.me.playlistsStore.clearFilter();
	   							J.me.playlistsStore.filter('playlistName', re);
	   						}
	   					}
	   				}
	   			}
	   		}],
	   		bbar: [ 'Position : ', PositionField],
			listeners: {
                rowclick: function(){
                   var selection = x.playlistPanel.getSelectionModel().getSelections();
				x.controller.model.reqAddToPlaylists([selection[0].data.playlistId]); 
                }
                
            }
	   	});
	  
		
        this.win = new J.Popup({
            title: tr("playlistAdder_title"),
            height: 300,
            layout: 'fit',
            closable: true,
            border: false,
            maximizable: true,
            scope: this,
            content: this.playlistPanel,
            buttons: [{
                text: tr('popup_button_close'),
                scope: this,
                handler: this.close
            }]
        });
        
        
    },
    close: function(){
    
        this.win.close();
    },
    renderSubmitting: function(){
        Ext.MessageBox.wait(tr("popup_button_wait"));
    },
    
    renderSubmitted: function(){
        Ext.MessageBox.hide();
    }
});
J.View.Home = Ext.extend(J.View.Base, {


	init: function() {

	},
	render: function(home){
		
        if (this.panel) {
            this.panel.destroy();
        }
        
		if (home) {
			this.home = home;
			if(home.items){
				this.panel = new Ext.ux.MainPortal(home);
			}
		}
    },
	
	destroy: function() {
		J.fc.getZone("adMediumRectangle", true).show();
		Ext.ComponentMgr.get("zone-socialMenu").hideMode = "display";
		Ext.ComponentMgr.get("zone-socialMenu").show();
		if(this.panel){
			this.panel.destroy();
		}
	}
	
});

J.View.Focus = Ext.extend( J.View.Base, {
	index: 3,
	run: true,
	time: 7000,
	downloadIndex : 0,
	modeDownload:false,
	lastselected: 0,
	task: {
			run: function() {
			
				J.focus.next(J.focus.lastselected);
			},
			scope:this,
			interval: 7000
			// 1 second
	},
	buttons : [],
	render: function(focus) {
		
		
		J.focus = this;
		this.zone = J.fc.getZone("focus");	
		this.focus = focus;
		var data = this.focus.getAllData();
		
		
		
		J.fc.getZone("socialMenu", true).hide();
		J.fc.getZone("adMediumRectangle", true).hide();
		J.fc.getController("ad", true).hideView("squareEast");
		J.fc.getZone("focus", true).show();
		
		this.zone.update('');
		this.panel = this.zone.createChild({
			cls: "focus-bg",
			style: "position: relative",
			children: [{
				cls: "focus-img"
			}, {
				cls: "focus-mask"
			}, {
				cls: "focus-column"
			}, {
				cls: "focus-line",
				id:'focus-blackline',
				children: [{
					cls: "focus-subtitle",
					html: ""
				}, {
					cls: "focus-title",
					html: ""
				}, {
					cls: "focus-actions"
				}]
			}]
		});
		
	
		
	
		var column =this.zone.child(".focus-column");
		
		for (var i = 0; i < 4; i++) {
			
			if(data[i].title.length > 20){
				var aWords = data[i].title.split(" ");
				var iNbrLetter = 0;
				for(j = 0; j < aWords.length; j++){
					if((iNbrLetter+aWords[j].length) > 20){
						break;
					}
					iNbrLetter += aWords[j].length + 1;
				}
				var TitleTexte = data[i].title.substring(0, iNbrLetter-1) + "<br/>" + data[i].title.substring(iNbrLetter, data[i].title.length);
			}else{
				var TitleTexte = data[i].title + (data[i].subtitle ? ('<div class="focus-tab-subtitle">' +J.render.reduce(data[i].subtitle,20)  + '</div>') : '');
			}
			this.buttons[i] = new Ext.DivButton({
				buttonI: i,
				cls: "focus-tab",
				enableToggle: true,
				renderTo: column,
				text:TitleTexte,
				//text: J.render.reduce(data[i].title,20) + (data[i].subtitle ? ('<div class="focus-tab-subtitle">' +J.render.reduce(data[i].subtitle,20)  + '</div>') : ''),
				toggleGroup: "focus",
				handler: this.toggleHandler,
				scope: this,
				width: 120
			});
			
			this.buttons[i].on('click',function(){J.focus.run=false;},this);
			
		}
		
		
		this.line = Ext.get('focus-blackline');
		
		this.mask =this.panel.child(".focus-mask");
			this.imageSelected =this.panel.child(".focus-img");
			this.actions = this.panel.child(".focus-actions");
			
		this.runner = new Ext.util.TaskRunner();
			
		this.runner.start(this.task);
	
		
	},
	next: function(selected) {
		
		
		if(this.modeDownload){
			
			this.selectDownload(selected);
			this.lastselected++;
			if(selected ==12){
				this.modeDownload = false;
				this.select(0);
				
			}
			
			
		}else if (this.run) {
				if (selected + 1 < 4) {
					this.select(selected + 1);
				} else {
					this.select(0);
				}
			}
			
		},
		
	selectDownload: function(selected) {
		
		
			this.imageSelected.dom.style.backgroundImage = 'url(/res/img/edito/'+(selected+1)+'.png)';
			this.imageSelected.fadeIn({
					endOpacity: 1, // can be any value between 0 and 1 (e.g. .5)
					easing: 'easeIn',
					duration: .4
			});
			
			
	},
	select :function(i){
		
		
		this.lastselected = i;
		var ob = this.focus.getData(i);
		
		if (this.buttons[i]) {
            this.buttons[i].toggle(true);
        }
		
		/*if (ob.special){
			this.lastselected = 0;
			this.modeDownload =true;
			this.task.interval = 3000;
			this.run =false;
			this.line.hide();
			this.next(0);
			this.mask.on('click',function(){
				if (!J.me.isLoggedIn()) {
					J.fc.getController('account',true).requireLogin();
				}
				else {
						J.fc.gotoUrl('account','download');
				}
			
				});
		
		}else {*/
		this.task.interval = 7000;
		this.mask.removeAllListeners();
		this.line.show();
		
		this.panel.child(".focus-subtitle").update(ob.subtitle);
		this.panel.child(".focus-title").update(ob.title);
		
		var actions = [];
		
		if (ob.link && ob.url) {
			actions.push({
				type: 'external_link',
				//target: '_blank',
				href: ob.url,
				html: ob.link
			});
			
		}
		
		if(ob.type && ob.objId >0){
			actions.push({
				type: 'play',
				source: ob.type,
				id: ob.objId
			});
		}else{
			
			if(ob.track){
				actions.push({
				type: 'track',
				id: ob.track.trackId
			});
			}
			
		}

		
			
		this.imageSelected.dom.style.backgroundImage = 'url(' + J.MEDIAPATH + "/edito/494/" + ob.image + '.jpg)';

			
		this.imageSelected.fadeIn({
			endOpacity: 1, // can be any value between 0 and 1 (e.g. .5)
			easing: 'easeIn',
			duration: .7
		});
			
			
		this.actions.update("");
		var renderAction = this.actions;
		
		/*if(ob.download){

			var button = {
				renderTo: renderAction,
				cls: "focus-action",
				iconCls: "focus-action-details",
				text : 'Accédez à la page des téléchargements'
			};
			
			button.handler = function(){
				if (!J.me.isLoggedIn()) {
					J.fc.getController('account',true).requireLogin();
				}else {
					J.fc.gotoUrl('account','download');
				}
			}
								
			new Ext.SimpleButton(button);
			
			
		}else{*/
				
		Ext.each(actions, function(action){
	
			var button = {
				renderTo: renderAction,
				cls: "focus-action",
				iconCls: "focus-action-details"
			};
			
			switch (action.type) {
			
				case 'external_link':{
				
					button.text = action.html;
					button.handler = function(){
					
						if (action.href.indexOf('http') == 0) {
							window.open(action.href);
						}
						else {
							document.location =action.href;
						}
					}
					break;
				}
				
					
				case 'play':{
				
					button.text = tr('play_'+J.render.typeRender(action.source));
					
					button.handler = function(){
					
						J.fc.getController(J.render.typeRender(action.source),true).play(action.id);
					}
					break;
				}
				
				case 'track':{
				
					button.text = tr('play_track');
					
					button.handler = function(){
					
						J.fc.getController('track',true).play(action.id);
					}
					break;
				}
				
			}
				
			new Ext.SimpleButton(button);
		});
		//}
		//}
	},
	toggleHandler: function(button, state) {
		this.select(button.buttonI);
		this.run =false;
	},
	destroy: function() {
		J.fc.getZone("socialMenu", true).show();
		J.fc.getZone("adMediumRectangle", true).show();
		if(this.panel){
			this.panel.remove();
		}
		
		J.fc.getController("ad", true).showView("squareEast");
		
	}
});

J.View.Text = Ext.extend( J.View.Base, {

	render: function() {
	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">'+'</td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
	 
					'</tr>' +
					
					
					
					
									        	        // content
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	        
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +

	        	        '</td>' +
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
        });
	
		this.body =  Ext.get('albums');
	
	}


});
J.View.Suggestion = Ext.extend(Ext.DataView, {

	onSuccess: function(p) {
		
		this.panel.body.update("Votre Commentaire a été ajouté");
		
	},
	
	renderSubmitted: function(success) {
		Ext.MessageBox.hide();
		if(success) {
			this.el.child(".Comment-comment").highlight();
			this.formPanel.getForm().reset();
		}
	},

	constructor: function(p) {
		
		var tpl = new Ext.XTemplate('<table class="commentList" cellpadding=0 cellspacing=0>' +
		'<tbody>' +
		'<tpl for=".">' +
		'<tr class="commentList-comment" id="{commentId}">' +
		'<td class="comment-td-illustration">' +
		'<a href="#user/{userId}">'+
								
								'<div class="cadre">' +
										'<div class="cadre-top"></div>' +
										'<div class="illustrationWrapper ">'+
												'<div class="cadre-center">'+
												'<img src="'+J.MEDIAPATH +'/user/100/{sex}{userId}.jpg" width="80"  />' +
												'<div class="cadre-bottom"></div>'+
													'</div>' +	
															
										'</div>' +								
										
								'</div>'+	
								
		'</a>' +
		'</td>' +
		
		'<td class="comment-td-text">' +
		'<div class="comment-userName"><a href="#user/{userId}">{userName}</a><br/>'+
		' '+tr('suggest_this')+' {suggestionDate:this.dateRenderer} :</div><br/>' +
		'<div class="comment-body">{text}</div>' +

		'</td>' +
		'</tpl>' +
		'</tbody>' +
		
		'</table>');

		tpl.dateRenderer = J.render.date;
		
		/*************************************/
		var baseP = {
			tpl: tpl,
			store: p.store,
			style :'padding-right:10px',
			overClass: 'userGrid-over',
			itemSelector: 'div.userGrid-user-wraper',
			loadingText : tr('content_loading'),
			loadMask: true
		};
		for (var i in p) {
			baseP[i] = p[i];
		}
		baseP.cls = "userGrid " + baseP.cls;
		J.View.Comment.superclass.constructor.call(this, baseP);
		
		this.bbar = new Ext.ActionPagingToolbar({
			cls: "contentBottomPaging",
			emptyMsg : '',
			store: p.store,
			roundedBox: false,
			ActionPaging:false,
			renderTo: p.renderTo
		});	
	}
});
J.View.Mail = Ext.extend(Ext.DataView, {

emptyText :'Chargement En Cours...',
	deferEmptyText :true,
	onSuccess: function(p) {
		
		this.panel.body.update(tr('abgrabber_success_msg'));
	
	},
	renderSubmitting: function() {
		Ext.MessageBox.wait(tr('wait')+"...");
	},
	
	renderSubmitted: function(success) {
		Ext.MessageBox.hide();
		if(success) {
			this.el.child(".commentList-comment").highlight();
			this.formPanel.getForm().reset();
		}
	},

	constructor: function(p) {
		
		var tpl = new Ext.XTemplate('<table class="commentList" cellpadding=0 cellspacing=0>' +
		'<tbody>' +
		'<tpl for=".">' +
		'<tr class="commentList-comment" id="{commentId}">' +
		'<td class="comment-td-illustration">' +
		'<a href="#user/{userId}">'+
								
								'<div class="cadre">' +
										'<div class="cadre-top"></div>' +
										'<div class="illustrationWrapper ">'+
												'<div class="cadre-center">'+
												'<img src="'+J.MEDIAPATH +'/user/80/{userPicture}.jpg" width="80"  />' +
												'<div class="cadre-bottom"></div>'+
													'</div>' +	
															
										'</div>' +								
										
								'</div>'+	
								
		'</a>' +
		'</td>' +
		
		'<td class="comment-td-text">' +
		'<div class="comment-userName"><a href="#user/{userId}">{userName}</a><br/>'+
		' '+tr('write_this')+' {sentTimestamp:this.dateRenderer} :</div><br/>' +
		'<div class="comment-body">{body}</div>' +

		'</td>' +
		'<td class="button-actions">' +
		
		'<div></div><div id="signal">'+tr("problem_header")+'</div>' +
			'<table height="100%"><tr><td></td></tr></table>' +
				
		'</td>' +
		'</tpl>' +
		'</tbody>' +
		
		'</table>');

		tpl.dateRenderer = J.render.date;
		
		/*************************************/
		var baseP = {
			tpl: tpl,
			style :'padding-right:10px',
			overClass: 'userGrid-over',
			itemSelector: 'div.userGrid-user-wraper',
			loadingText : tr('content_loading'),
			loadMask: true
		};
		
		for (var i in p) {
			baseP[i] = p[i];
		}
		
		baseP.cls = "userGrid " + baseP.cls;
		J.View.Comment.superclass.constructor.call(this, baseP);
		
		
		this.formPanel= new Ext.FormPanel({
			labelAlign: 'top',
		
			border: false,
			items: [{ xtype:'textarea',
					 fieldLabel:'<b>'+tr('reply_to_this')+'</b>',
					 height:100,
					 anchor:'90%',
					 allowBlank: true,
					name: 'body'
			}]
		});

		this.panel = new Ext.Panel({
		    layout:'column',
			renderTo :p.renderTo,
			style :'padding:10px',
			bodyStyle:'padding:10px 15px 0;background-color:#f7f7f6;',
			border:false,
			frame :true,
		    items: [{
		        columnWidth: 1 ,
				border:false,
				items:	[this.formPanel]  },{
		      	width: 180,
				border:false,
			  	cls :"button-actions"
		    }]
		});
		
		var actionsRenderTo = this.panel.body.child(".button-actions");

        var button = actionsRenderTo.createChild({
					html: tr('send_this_msg')
		});
		
		
					 
		button.on('click',function(){
		
			this.controller.onPost(this.formPanel.getForm().getValues());
			
			
		},this);
		
			
	}
});
J.View.Comment = Ext.extend(Ext.DataView, {
	ads:false,
    onSuccess: function(p){
    
        this.panel.body.update("Votre Commentaire a été ajouté");
        
    },
	onRender : function(ct,position){
        if(!this.el){
            this.el = document.createElement('div');
            this.el.id = this.id;
        }
	
		
        Ext.DataView.superclass.onRender.apply(this, arguments);
    },
	
    renderSubmitted: function(success){
        Ext.MessageBox.hide();
        if (success) {
            this.el.child(".commentList-comment").highlight();
            this.formPanel.getForm().reset();
        }
    },
    
    getAds: function(){
    
				var controller = J.fc.getController('ad',true);
				var selectPub = Math.floor(Math.random()*controller.urlList.length);
				var url = controller.urlList[selectPub];
				
				var srcBan = "/googleAds.php?format=h&image=true&language="+J.Language.languageCode+"&urlContent="+url+"&name="+J.fc.name;
				
				return '<iframe  SRC="' + srcBan + '" WIDTH="100%"  height="65" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no ALIGN=MIDDLE ></iframe>';
				
				
    
    }, constructor: function(p){
    
        var tpl = new Ext.XTemplate('<table class="commentList" cellpadding=0 cellspacing=0>' +
        '<tbody>' +
        '<tpl for=".">' +
        '<tr class="commentList-comment" id="{commentId}">' +
        '<td class="comment-td-illustration">' +
        '<a href="#user/{userId}">' +
        '<div class="cadre">' +
        '<div class="cadre-top"></div>' +
        '<div class="illustrationWrapper ">' +
        '<div class="cadre-center">' +
        '<img src="' +
        J.MEDIAPATH +
        '/user/80/{userPicture}.jpg" width="80" />' +
        '<div class="cadre-bottom"></div>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '</a>' +
        '</td>' +
        '<td class="comment-td-text">' +
        '<div class="comment-userName"><a href="#user/{userId}">{userName}</a><br/>' +
        ' ' +
        tr("write_this") +
        ' {insertDate:this.dateRenderer} :</div><br/>' +
        '<div class="comment-body">{body}</div>' +
        '</td>' +
        '<td class="button-actions">' +
        '<div onclick="J.fc.controller.commentController.onProblem({commentId})" id="signal">' +
        tr("problem_header") +
        '</div>' +
        '<tpl if="this.mine()==true"><div onclick="J.fc.controller.commentController.deleteComment({commentId})" id="delete-comment">' +
        tr("delete_comment") +
        '</div></tpl>' +
        '<table height="100%"><tr><td></td></tr></table>' +
        '</td>' +
        '</tpl>' +
        '</tbody>' +
        
        '</table>', J.fc.controller);
        
        tpl.dateRenderer = J.render.date;
        
        
        
        /*************************************/
        var baseP = {
            tpl: tpl,
            style: 'padding-right:10px',
            overClass: 'userGrid-over',
            itemSelector: 'div.userGrid-user-wraper',
            loadingText: tr('content_loading'),
            loadMask: true
        };
        for (var i in p) {
            baseP[i] = p[i];
        }
        baseP.cls = "userGrid " + baseP.cls;
		
		  this.formPanel = new Ext.FormPanel({
            labelAlign: 'top',
            border: false,
            items: [{
                xtype: 'textarea',
                fieldLabel: '<b>' + tr('comments_post') + '</b>',
                height: 100,
                anchor: '90%',
                allowBlank: true,
                name: 'body'
            }]
        });
        
        this.panel = new Ext.Panel({
            layout: 'column',
            renderTo: p.renderTo,
            style: 'padding:10px 10px 10px 10px',
            bodyStyle: 'padding:10px 15px 0;background-color:#f7f7f6;',
            border: false,
            frame: true,
            items: [{
                columnWidth: 1,
                border: false,
                items: [this.formPanel]
            }, {
                width: 180,
                border: false,
                cls: "button-actions"
            }]
        });
        
        var actionsRenderTo = this.panel.body.child(".button-actions");
        
        var button = actionsRenderTo.createChild({
            html: tr('add_comments')
        });
        
        button.on('click', function(){
        
            this.controller.onPost(this.formPanel.getForm().getValues());
            
        }, this);
		
		new Ext.Panel({
            renderTo: p.renderTo,
            border: false,
            items: [{
				html: this.getAds()
            }]
		});
		
        J.View.Comment.superclass.constructor.call(this, baseP);
        
        this.bbar = new Ext.ActionPagingToolbar({
            cls: "contentBottomPaging",
            emptyMsg: '',
            store: p.store,
            roundedBox: false,
            ActionPaging: false,
            renderTo: p.renderTo
        });
		
		 
      
    }
});
J.View.Artist = Ext.extend(J.View.Card, {
	tplContent :'<tpl>'+
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Artiste</span></div></tpl>'+
	'<tpl><h1>{artistName}</h1></tpl>'+
	'<tpl if="this.isset(biography)">{values.biography.summary:this.Bigreduce}<br/><br/></tpl>'+
	'<tpl if="nbSongs"><b>'+tr('nbTracks')+' :</b> {nbSongs}</br></tpl>'+
	'<tpl if="this.isset(style)"><b>'+tr('select_themes')+' :</b>'+
		' {style:this.styleRender}'+
		'<tpl if="this.isset(styleSecondary)" >'+' - {styleSecondary:this.styleRender}'+'</tpl>'+
	'</tpl>'+
	'<br/>'+
	'<tpl if="nbSubscribers"><b>'+tr('nbSubscribers')+' :</b> {nbSubscribers}</br></tpl>'+
	//'<tpl if="this.isset(style)"><b>'+tr('select_themes')+' :</b> {style:this.styleRender} </br></tpl>'+
	'<tpl if="this.isset(artists.page)"><br/><br/><br/><b>'+tr('trackGrid_header_artistName')+'(s) : </b>{artists:this.formatArtists}</br><br/></tpl>'+
	'<tpl ><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td> {artistPopularity:this.popularityRenderer}</td></tr></table></br></tpl>'+
	'<tpl if="this.isset(tags)"><b>Tags : </b>{tags:this.formatTagsPublic}<br/><br/></tpl>'+
	'</tpl>', 
    imageSize : "131",
	
	/*
	 * Définit quel Template de ToppViewCard 
	 * sera affiché et dans quel ordre
	 * (dont le chiffre est à choisir dans viewCardTemplate.js)
	 * Les top sont définit dans cet ordre : gauche - centre - droit
	 */
	
	menu:{
		normal:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		
		},
		admin:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		}
	},
	options : {
            title: "Fiche Artiste",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}, {
                id: "signal",
                text: 'problem_header'
            }],
            categories: [{
                id: "fullText",
                text: 'all_biography'
            },{
                id: "subscribers",
                text: 'all_fans'
            },  {
                id: "albums",
                text: 'all_albums'
            }, {
                id: "tracks",
                text: 'all_tracks'
            },{
                id: "comments",
                text: 'all_comments'
            }],
            
            actions: [{
                id: "subscribe",
                text: "artist_add_to_favourite"
            },{
                id: "unsubscribe",
                text: "artist_remove_to_favourite"
            },{
                id: "share",
                text: "share_link"
            }],
			admin :[{
                id: "edit-button",
                text: "edit-artist"
            },{
                id: "edit-genre",
                text: "edit-genre"
            },{
                id: "edit-picture",
                text: "change_picture"
            },{
                id: "edit-delete",
                text: 'delete'
            },{
                id: "edit-tag",
                text: 'to_tag'
            }]
        }
		
 
});
J.View.Album = Ext.extend(J.View.Card, {
	tplContent :'<tpl>'+
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Album</span></div></tpl>'+
	'<tpl><h1>{albumName}</h1></tpl>'+
	'<tpl if="nbSongs"><b>'+tr('nbTracks')+' :</b> {nbSongs}<br/></tpl>'+
	'<tpl if="nbSubscribers"><b>'+tr('nbSubscribers')+'  :</b> {nbSubscribers} <br/></tpl>'+
	'<tpl if="this.isset(releaseDate)"><b>'+tr('album_infos_releaseDate')+' :</b> {releaseDate:this.dateRenderer}<br/></tpl>'+
	'<tpl if="this.isset(style)"><b>'+tr('select_themes')+' :</b>'+
		' {style:this.styleRender}'+
		'<tpl if="this.isset(styleSecondary)" >'+' - {styleSecondary:this.styleRender}'+'</tpl>'+
	'</tpl>'+
	'<br/>'+
	'<tpl if="this.isset(artists.page)"><b>'+tr('trackGrid_header_artistName')+'(s) : </b>{artists:this.formatArtists}<br/><br/></tpl>'+

	'<tpl ><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td> {albumPopularity:this.popularityRenderer}</td></tr></table><br/></tpl>'+
	'<tpl if="this.isset(hidden)"><table><tr><td><b class="cardview-not-accessible">'+tr('album_not_accessible')+'</b></td></tr></table><br/></tpl>'+
	'<tpl if="this.isset(restricted)"><table><tr><td><b class="cardview-not-accessible">'+tr('album_is_restricted')+'</b></td></tr></table><br/></tpl>'+
	
	'<tpl if="this.isset(tags)"><b>Tags : </b>{tags:this.formatTags}<br/><br/></tpl>'+
	'</tpl>',
	imageSize : "131",
	menu:{
		normal:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		
		},
		admin:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		}
	},
	options : {
            title: "Fiche Album",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}, {
                id: "signal",
                text: 'problem_header'
            }],
            categories: [{
                id: "tracks",
                text: 'all_tracks'
            },{
                id: "subscribers",
                text: 'all_fans'
            },{
                id: "comments",
                text: 'all_comments'
            }],            
            actions: [{
                id: "subscribe",
                text: 'album_add_to_favourite'
            }, {
                id: "unsubscribe",
                text: 'album_remove_to_favourite'
            }, {
                id: "share",
                text: "share_link"
            },{
                id: "download",
                text: 'download'
            }],
			admin :[{
                id: "edit-button",
                text: "Editer ce titre"
            }, {
                id: "edit-rename",
                text: 'rename'
            },{
                id: "edit-picture",
                text: "change_picture"
            },{
                id: "edit-recommendation-check",
                text: 'select_recommendation'
            },{
                id: "edit-recommendation-uncheck",
                text: 'unselect_recommendation'
            },{
                id: "buy",
                text: 'buy'
            }]
        }
 
});J.View.News = Ext.extend(J.View.Card, {
		tplPanel : '<table cellpadding=0 cellspacing=0 width="100%">' +
            '<tr><td width="681">' +
            
            '<table cellpadding=0 cellspacing=0 class="detail-header">' +
            '<tr>' +
            '<td class="detail-header-left">' +
            '</td>' +
            '<td class="detail-header-title" ><table width="100%"><tr><td  id ="detail-header-title"></td ><td  id ="detail-header-msg"></td></tr></table></td>' +
            '<td class="detail-header-right">' +
            '</td>' +
            '</tr>' +
            '</table>' +
            '</td>' +
            '<td>' +
            '</td>' +
            '</tr>' +
            '<tr  height="100%"><td>' +
            '<table cellpadding=0 cellspacing=0 id="detail-summary" height="100%" class="detail-summary news">' +
            '<tr>' +
         	'<td id="detail-top-content" height="100%" >' +
			
	            '<div id="illustrationWrapper" >' +
	            	'<div  class="cadre">' +
	            	'<div class="cadre-top"></div>' +
	           		 '<div class="illustrationWrapper">' +
	            		'<img  id="illustration" width="131"  />' +
	          		  	'<div class="cadre-bottom"></div>' +
	            	'</div>' +
	            	'</div>' +
	            '</div>' +
            '<div id="detail-col-infos" >' +
            '</div>' +
			 '</td>' +
			 '<td>' +
            '<div id="detail-col-actions" class="button-actions">' +
            '</div>' +
            '</td>' +
            '</tr>' +
            
            '<tr>' +
            '<td  colspan=2 id="detail-top-content">' +
            '<div id="detail-col-down">' +
            '</div >' +
            '</td>' +
            '</tr>' +
            '</table>' +
            '</td>' +
            '<td class="top-col" >' +
            '<div class="detail-categories-top"></div>' +
            '<div id="detail-permalien" class="detail-col-categories" ></div>' +
            '<div class="detail-categories-bottom"></div>' +
            '</td>' +
            '</tr>' +
            // separator
            
            
            
            // content
            '<tr id="detail-row-bottom">' +
            
            '<td id="detail-col-bodyWrapper" >' +
            '<table cellpadding=0 cellspacing=0>' +
            '<tr>' +
            '<td id="detail-col-title" class ="body-title">' +
            '</td>' +
            '<td id="actionMenu">' +
            '</td>' +
            '</tr>' +
            '</table>' +
            '<div id="detail-col-body">' +
            '</div>' +
            '</td>' +
            '<td id="detail-col-categoriesWrapper">' +
            '<div id="detail-categories">'+
    '<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="detail-col-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	'</div>'+
			    '<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	
			
	 
            '</td>' +
            '</tr>' +
            
            
            '<tr>' +
            
            '<td>' +
            // footer
            '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
            '<tr>' +
            '<td class="detail-footer-left">' +
            '</td>' +
            '<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
            tr("gotoupperPage") +
            '</td>' +
            '<td class="detail-footer-right">' +
            '</td>' +
            
            '</tr>' +
            '</table>' +
            
            '</td>' +
            '<td >' +
            '</td>' +
            '</tr>' +
            '</table>',
	tplContent :'<tpl>'+
	'<tpl if="this.isset(title)"><h1>{title}</h1></tpl>'+
	'<tpl if="this.isset(publishDate)">'+tr('published')+' {publishDate:this.date}<br/></tpl>'+
	'<tpl if="this.isset(artists.page)"><b>'+tr('trackGrid_header_artistName')+'(s) : </b>{artists:this.formatArtists}<br/><br/></tpl>'+
	'<tpl if="this.isset(text)"><br/>{text}</br></tpl>'+
	'<tpl if="this.isset(text)==false"><br/>{thread}</br></tpl>'+
	'<tpl if="this.isset(tags)"><b>Tags : </b>{tags:this.formatTags}<br/><br/></tpl>'+
	'</tpl>', 
    imageSize : "131",
    setImage: function(image){
    
         this.imageEl.dom.src = image + '?r=' + Math.random();
		 
		 if(this.controller.model.getField('format')=="7"){
		 	this.tplContent = '<tpl>'+
			'<tpl if="this.isset(title)"><h1>{title}</h1></tpl>'+
			'<tpl if="this.isset(publishDate)">'+tr('published')+' {publishDate:this.date}<br/></tpl>'+
			'<tpl if="this.isset(artists.page)"><b>'+tr('trackGrid_header_artistName')+'(s) : </b>{artists:this.formatArtists}<br/><br/></tpl>'+
			'<tpl if="this.isset(thread)"><br/>{thread}<br/></tpl>'+
			'<tpl if="this.isset(text)"><br/><br/><center>{text}</center><br/></tpl>'+
			'<tpl if="this.isset(tags)"><b>Tags : </b>{tags:this.formatTags}<br/><br/></tpl>'+
			'</tpl>';
			
			Ext.get("illustrationWrapper").setVisibilityMode(Ext.Element.DISPLAY).hide();
			
		 }else{
		 	Ext.get("illustrationWrapper").setVisibilityMode(Ext.Element.DISPLAY).show();
		 }
    },
	menu:{
		normal:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		
		},
		admin:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		}
	},
	options : {
            categories: [],
            actions: [],
			admin :[{
                id: "edit-button",
                text: "Editer cette News"
            },{
                id: "edit-picture",
                text: "change_picture"
            },{
                id: "edit-picture-focus",
                text: "change_picture_focus"
            },{
                id: "edit-delete",
                text: 'delete'
            }]
        },
		
 renderPreview: function(news){
		var text = news.getField("text");
		text = text.replace(/\[photocenter\](.*)\[\/photocenter\]/, "<div style='text-align:center; margin:15px;'><img src=\"http://www.chartsinfrance.net/blog/images/$1\" /></div>");
		text = text.replace(/\[photoleft\](.*)\[\/photoleft\]/, "<img style='float:left; border: 1px solid #000000; margin: 15px 15px 15px 0;' src=\"http://www.chartsinfrance.net/blog/images/$1\" />");
		text = text.replace(/\[photoright\](.*)\[\/photoright\]/, "<img style='float:right; border: 1px solid #000000; margin: 15px 0 15px 15px;' src=\"http://www.chartsinfrance.net/blog/images/$1\" />");
		text = text.replace(/\[(.*)->(.*)\]/, "<a href=\"$2\">$1</a>");
		text = text.replace(/\[dailymotion\](.*)\[\/dailymotion\]/, '<div style="margin:15px" align="center"><object height="341" width="425"><param value="http://www.dailymotion.com/swf/$1&amp;v3=1&amp;colors=background:FFFFFF;glow:FFFFFF;foreground:4391C3;special:4391C3;&amp;related=0" name="movie"/><param value="true" name="allowFullScreen"/><param value="always" name="allowScriptAccess"/><embed height="341" width="425" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/x79n9c&amp;v3=1&amp;colors=background:FFFFFF;glow:FFFFFF;foreground:4391C3;special:4391C3;&amp;related=0"/></object></div>');
		text = text.replace(/\[youtube\](.*)\[\/youtube\]/, '<div style="margin:15px" align="center"><object height="355" width="425"><param value="http://www.youtube.com/v/nOtodC72J0&amp;rel=0&amp;color1=0x4391C3&amp;color2=0x54abd6&amp;border=0" name="movie"/><param value="transparent" name="wmode"/><embed height="355" width="425" wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/v/$1&amp;rel=0&amp;color1=0x4391C3&amp;color2=0x54abd6&amp;border=0"/></object></div>');
		text = text.replace(/{{(.*)}}/, '<i>$1</i>');
		text = text.replace(/{(.*)}/, '<b>$1</b>');
			
    }
});
J.View.Playlist = Ext.extend(J.View.Card, {
    //MAXBIOGRAPHYSUMMARYLENGTH: 700,
	tplContent :'<tpl>'+
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Playlist</span></div></tpl>'+
	'<tpl><h1>{playlistName}</h1></tpl>'+
	'<tpl if="this.isset(description)"><b>'+tr('description')+' :</b> {description}<br/><br/></tpl>'+
	'<tpl ><b>'+tr('nbTracks')+' :</b> {nbSongs}<br/></tpl>'+
	'<tpl if="nbSubscribers"><b>'+tr('nbSubscribers')+' :</b> {nbSubscribers}<br/></tpl>'+
	'<tpl if="this.isset(style)"><b>'+tr('select_themes')+' :</b> {style:this.styleRender}<br/></tpl>'+
		'<br/>'+
	'<tpl if="this.isset(playlistPopularity)"><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td> {playlistPopularity:this.popularityRenderer}</td></tr></table><br/></tpl>'+
	'<b> '+tr('par')+' :</b> <a href="#user/{ownerId}">{ownerName}</a>'+
	'<br/>'+
	'<br/>'+
	'<tpl if="this.isset(tags)"><b>Tags : </b>{tags:this.formatTags}<br/><br/></tpl>'+	

	tr('playlistGrid_header_modificationDate')+' : {modificationDate:this.dateRenderer}<br/><br/>'+
	
	'<tpl if="this.mine()">({private:this.privateRender})</tpl>'+
	'<br/>'+
	'</tpl>'+
	
	'</tpl>',
    imageSize : "131",
		menu:{
		normal:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		
		},
		admin:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				},
				{
					text: tr('delete'),
					handler: function(){
						J.fc.grid.removefromPlaylist(true);
					}
				}
			]
		}
	},options : {
			title: "Fiche playlist",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}],
			categories: [{
				id: "tracks",
				text: "all_tracks"
			}, {
				id: "subscribers",
				text: "all_subscribers"
			}, {
				id: "comments",
				text: "all_comments"
			}],
			actions: [ {
                id: "subscribe",
                text: "playlist_add_to_favourite"
            }, {
                id: "unsubscribe",
                text: "playlist_remove_to_favourite"
            }, {
                id: "share",
                text: "share_link"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			admin :[{
                id: "edit-button",
                text: "edit_playlist"
            },{
                id: "edit-picture",
                text: 'change_picture'
            }, {
                id: "edit-delete",
                text: 'delete'
            }, {
                id: "share",
                text: "share_link"
            },  {
                id: "permalink",
                text: "copy_link"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			staff :[{
                id: "edit-recommendation-check",
                text: 'select_recommendation'
            },{
                id: "edit-recommendation-uncheck",
                text: 'unselect_recommendation'
			}]
        }
 
});
J.View.Station = Ext.extend(J.View.Card, {
	tplContent :'<tpl>'+
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Radio</span></div></tpl>'+
	'<tpl><h1>{radioName}</h1></tpl>'+
	'<tpl if="this.isset(radioDescription)"><div class="biography-summary">{radioDescription}<br/><br/></div></tpl>'+
	'<tpl if="nbSubscribers"><b>'+tr('nbSubscribers')+'  :</b> {nbSubscribers}<br/><br/></tpl>'+
	'<tpl if="this.isset(radioPopularity)"><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td> {radioPopularity:this.popularityRenderer}</td></tr></table>'+'</tpl>'+
	
	'</tpl>', 
	imageSize : "131",
	isFan : ''+tr('subscribe')+' à cette radio ',
	isNotFan : "tr('unsubscribe') à cette radio ",
	options : {
            title: "Fiche Radio",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}],
            categories: [{
                id: "subscribers",
                text: 'all_fans'
            }, {
                id: "comments",
                text: 'all_comments'
            }],            
            actions: [{
                id: "subscribe",
                text: "radio_add_to_favourite"
            }, {
                id: "unsubscribe",
                text: "radio_remove_to_favourite"
            },  {
                id: "share",
                text: "share_link"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			admin :[{
                id: "edit-rename",
                text: 'rename'
            },{
                id: "edit-tag",
                text: 'to_tag'
            }, {
                id: "edit-picture",
                text: 'change_picture'
            }, {
                id: "edit-delete",
                text: 'delete'
            }, {
                id: "share",
                text: "share_link"
            },  {
                id: "permalink",
                text: "copy_link"
            }]
        }
 
});J.View.Track = Ext.extend(J.View.Card, {
	tplContent : '<tpl>' +
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Titre</span></div></tpl>'+
	'<tpl><h1>{songName}</h1></tpl>'+
	'<b>'+tr('trackGrid_header_artistName')+'(s) : </b><a href="#artist/{artistId}">{artistName}</a><br/><br/>'+

	 '<b>Album : </b><a href="#album/{albumId}">{albumName}</a><br/><br/>'+
	 '<tpl if="this.isset(style)"><b>'+tr('select_themes')+' :</b>'+
		' {style:this.styleRender}'+
		'<tpl if="this.isset(styleSecondary)" >'+' - {styleSecondary:this.styleRender}'+'</tpl>'+
	'</tpl>'+
	'<br/>'+
	 '<tpl if="this.isset(songPopularity)"><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td> {songPopularity:this.popularityRenderer}</td></tr></table><br/></tpl>'+
	 '<tpl if="this.isset(hidden)"><table><tr><td><b class="cardview-not-accessible">'+tr('track_not_accessible')+'</b></td></tr></table><br/></tpl>'+
	 '<tpl if="this.isRestricted(restricted)"><table><tr><td><b class="cardview-not-accessible">'+tr('track_is_restricted')+'</b></td></tr></table><br/></tpl>'+
	 '<tpl if="this.isNotPlayable(restricted)"><table><tr><td><b class="cardview-not-accessible">'+tr('track_not_available')+'</b></td></tr></table><br/></tpl>'+
	 '<tpl if="this.isset(tags)"><br/><b>Tags : </b>{tags:this.formatTags}<br/><br/></tpl>'+	
	 '</tpl>',
	imageSize : "131",
	options : {
            title: "Fiche Titre",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}],
            categories: [{
                id: "suggestions",
                text: "summary"
            }, {
                id: "comments",
                text: 'all_comments'
            }],
           actions: [ {
                id: "play",
                text: "play"
            },{
                id: "addToPlayer",
                text: "addToPlayer"
            },{
                id: "addToPlaylist",
                text: "addToPlaylist"
            },{
                id: "addToNewPlaylist",
                text: "addToNewPlaylist"
            },{
                id: "suggest",
                text: 'suggestion_popup_header'
            },{
                id: "share",
                text: "share_link"
            },{
                id: "download",
                text: "download"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			admin :[{
                id: "edit-button",
                text: "Editer ce titre"
            },{
                id: "edit-upload",
                text: "Uploader"
            },{
                id: "edit-download",
                text: "download"
            },{
                id: "edit-delete",
                text: 'delete'
            }]
        }
 
});
J.View.User = Ext.extend(J.View.Card, {
	tplContent :'<tpl>'+
	'<tpl><div class="head-name-cardview"><span class="head-name-cardview-title">Univers</span></div></tpl>'+
	'<tpl><h1>{userName}</h1></tpl>'+
	'<tpl if="this.isset(tastes)"><b>'+tr('universe_profile_label_description')+' : </b>{tastes}'+'<br/><br/></tpl>'+
	'<b>'+tr('Genre')+' : </b>'+
	'<tpl if="this.isBoy(sex) == true">'+tr('man')+'<br/> </tpl>'+
	'<tpl if="this.isWoman(sex) == true">'+tr('woman')+'<br/></tpl>'+
	'<tpl if="this.dateBornRender(bornDate)"><b>'+tr('Age')+' : </b> {bornDate:this.dateBornRender} <br/></tpl>'+
	'<tpl if="this.isset(interestedIn)"><b>'+tr('status')+' </b>: {relationshipStatus:this.relationchipRender}<br/></tpl>'+
	'<tpl if="this.isset(languages)"><b>'+tr('universe_profile_label_languages')+' :</b> {languages}'+'<br/></tpl>'+
	'<tpl if="this.isset(country)"><b>'+tr('user_popup_signup_label_country')+' :</b> {country}<tpl if="this.isset(town)">- {town}</tpl>'+'<br/></tpl>'+
	'<tpl if="this.isBoy(interestedIn) == true"><b>'+tr('label_interestedIn')+' : </b>'+tr('man')+'  <br/></tpl>'+
	'<tpl if="this.isWoman(interestedIn) == true"><b>'+tr('label_interestedIn')+' : </b>'+tr('woman')+'  <br/></tpl>'+
	'<tpl if="this.isset(town) == false"><b>'+tr('localisation')+' : </b>{countryId:this.countriesRender}<br/></tpl>'+
	'<tpl if="this.isset(town) == true"><b>'+tr('localisation')+' : </b>{countryId:this.countriesRender} - {town}<br/></tpl>'+
	'<br/>'+
	'<tpl if="this.isset(nbSubscribers)"><b>'+tr('nbSubscribers')+'  :</b> {nbSubscribers}<br/><br/></tpl>'+
	'<tpl ><table><tr><td><b>'+tr('trackGrid_header_popularity')+' :</b></td><td>{userPopularity:this.popularityRenderer}</td></tr></table></tpl>'+
		'<tpl if="this.is(supporter) == true"><br/><img src="/res/img/addict.jpg" /><br/></tpl>'+	
		'</tpl>',
    imageSize : "131",
	displayTop:{
		left: {
			index: 4,
			title: "Music Angels"
		},
		center:{
			index: 2,
			title: "Playlists favorites"
		},
		right:{
			index: 3,
			title: "Radios favorites"
		}
	},
	options : {
            title: "Fiche Univers",
			subs:[{
				id: 'similar-artist-button',
				text: 'card_similar_artist'
			},{
				id: 'play-button',
				text: 'card_play'
			},{
				id: 'tools-button',
				text: 'card_tools',
				admin: true
			}],
            categories: [{
                id: "playlists",
                text: "all_playlists"
            },{
                id: "suggestions",
                text: "all_suggestions"
            }, {
                id: "albums",
                text: "all_albums"
            },{
                id: "comments",
                text: 'all_comments'
            },{
				text:'',
				disabled:true
			},{
                id: "subscribers",
                text: "all_subscribers"
            },{
                id: "angels",
                text: "all_angels"
            },{
                id: "favoritesPlaylist",
                text: "all_favorites_playlists"
            },{
                id: "othersSuggestions",
                text: "all_others_suggestions"
            }],
            actions: [{
                id: "message",
                text: "universe_profile_button_write"
            }, {
                id: "subscribe",
                text: "angel_add_to_favourite"
            }, {
                id: "unsubscribe",
                text: "angel_remove_to_favourite"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			admin :[{
                id: "edit-button",
                text: "edit_profil"
            }, {
                id: "support-jiwa",
                text: 'support_jiwa'
            }, {
                id: "edit-picture",
                text: "change_picture"
            }, {
                id: "edit-delete",
                text: "delete_account"
            }, {
                id: "signal",
                text: 'problem_header'
            }],
			staff :[{
                id: "edit-recommendation-check",
                text: 'select_recommendation'
            },{
                id: "edit-recommendation-uncheck",
                text: 'unselect_recommendation'
			}]
        }
});



J.View.Account = Ext.extend(J.View.Base, {
    rendered: true,
    render: function(){
    
        this.zoneMenu = J.fc.getZone("accountMenu");
		
		this.RadioButton = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: false,
            toggleGroup: "mainMenu-buttons",
            text: 'Nos '+tr("mainMenu-radio"),
            cls: "account-myDiscoveryBox",
            scope: this,
            handler: function(){
               
                    J.fc.gotoUrl('radio');
            }
        });
		
		this.ChartsButton = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: false,
            scope: this,
            handler: function(){
               
                    J.fc.gotoUrl('top');
            }
        });
		//Encore en developpement
		this.ChartsButton = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: true,
            toggleGroup: "mainMenu-buttons-expand",
            text: tr("mainMenu-top"),
            cls: "account-myPlaylists",
            scope: this,
            handler: function(){
                 if (this.ChartsView.collapsed == true) {
                        this.ChartsView.expand();
						
						J.fc.gotoUrl('top', 'tracks');
                    }
                    else {
                        this.ChartsView.collapse();
                }
            }
        });
        
    

        this.ChartsView = new Ext.tree.TreePanel({
            cls: "account-items",
       	 	animate:true,
            collapsed: true,
            frame: true,
			rootVisible: false,
            border: false,
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            containerScroll: false,
            bodyStyle: 'background:#FFFFFF',
            id: 'charts-items',
            root: {children:[{
                    text: tr('all_tracks'),
                    href: "#top/tracks",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    iconCls: "account-item-img",
                    cls: "account-item",
                    leaf: true
                } ,{
                    text: tr('all_playlists'),
                    href: "#top/playlists",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    iconCls: "account-item-img",
                    cls: "account-item",
                    leaf: true

                },{
                    text: tr('all_albums'),
                    href: "#top/albums",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    iconCls: "account-item-img",
                    cls: "account-item",
                    leaf: true

                } 
			]
				
			}
        });
		
		this.myBoxButton = new Ext.SimpleButton({
			enableToggle: true,
            allowDepress: true,
            toggleGroup: "mainMenu-buttons-expand",
            text: tr("Music Box"),
            cls: "account-mySuggestions",
            scope: this,
            handler: function(){
                 if (!J.me.isLoggedIn()) {
                    this.controller.requireLogin();
                }
                else {
                  if (this.myBoxView.collapsed == true) {
                        this.myBoxView.expand();
						
						J.fc.currentSuggestion = "otherSuggestions";
						J.fc.gotoUrl('account', 'discoverybox');
	              } else {
						this.myBoxView.collapse();
	                }  
                }
				
            }
        });
        
		 
    

        this.myBoxView = new Ext.tree.TreePanel({
            cls: "account-items",
       	 	animate:true,
            collapsed: true,
            frame: true,
			rootVisible: false,
            border: false,
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            containerScroll: false,
            bodyStyle: 'background:#FFFFFF',
            id: 'myBox-items',
            root: {children:[{
                    text: tr('leftMenu_myDiscoveryBox'),
                    href: "#account/discoverybox",
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item",
                    leaf: true
                },{
                    text: tr('leftMenu_mySuggestions'),
                    href: "#account/suggestions",
                    iconCls: "account-item-img",
                    uiProvider: Ext.tree.TreeNodeUILeft,
                    cls: "account-item",
                    leaf: true
                }
			]
				
			}
        });
        
        
       
      
        
        this.myAlbums = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: false,
            toggleGroup: "mainMenu-buttons",
            text: tr("leftMenu_myAlbums"),
            cls: "account-myAlbums",
            scope: this,
            handler: function(){
                if (!J.me.isLoggedIn()) {
                    this.controller.requireLogin();
                }
                else {
                    J.fc.gotoUrl('account', 'albums');
                }
            }
        });
        
        this.createPlaylistButton = new Ext.SimpleButton({
            text: tr("playlist_popup_create_title"),
            id: 'account-playlist-button-add',
            cls: "account-add",
            scope: this,
            handler: function(){
                if (!J.me.isLoggedIn()) {
                    this.controller.requireLogin();
                }
                else {
                    J.fc.getController("playlist", true).create();
                }
            }
        });
        
        this.myPlaylists = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: true,
            pressed: true,
            toggleGroup: "mainMenu-buttons-expand",
            text: tr("leftMenu_myPlaylists"),
            cls: "account-myPlaylists",
            scope: this,
            handler: function(){
                if (!J.me.isLoggedIn()) {
                    this.controller.requireLogin();
                }
                else {
                    if (this.myPlayListContent.collapsed == true) {
                        if (J.me.isLoggedIn()) {
                            this.myPlayListContent.expand();
                        }
                     
                    }
                    else {
                        this.myPlayListContent.collapse();
                    }
                }
            }
        });
        this.mySubscriptions = new Ext.SimpleButton({
            enableToggle: true,
            allowDepress: true,
            toggleGroup: "mainMenu-buttons-expand",
            text: tr("mySubscriptions"),
            cls: "account-mySubscriptions",
            scope: this,
            handler: function(){
                if (!J.me.isLoggedIn()) {
                    this.controller.requireLogin();
                }
                else {
                    if (this.mySubscriptionsView.collapsed == true) {
                        this.mySubscriptionsView.expand();
                    }
                    else {
                        this.mySubscriptionsView.collapse();
                    }
                }
            }
        });
        
        
        this.mySubscriptionsView = new Ext.Panel({
            cls: "account-items",
            collapsed: true,
            frame: true,
            bodyStyle: 'background:#FFFFFF',
            id: 'subscriptions-items',
            items: [{
                id: 'subscriptions-radios'
            }, {
                id: 'subscriptions-artists'
            }, {
                id: 'subscriptions-angels'
            }, {
                id: 'subscriptions-playlists'
            }]
        });
        
        this.myPlayListContent = new Ext.Panel({
            id: 'my-playlist-content',
            collapsed: true,
            frame: true,
            bodyStyle: 'background:#FFFFFF',
            items: [this.createPlaylistButton, {
                cls: "account-items",
                id: 'playlists-items'
            }]
        });
        
        this.panelMenuOpening = new Ext.Panel({
            id: "panel-menu-opening",
            hideBorders: true,
            scope: this,
            items: [this.myPlaylists, this.myPlayListContent, this.mySubscriptions, this.mySubscriptionsView],
            bodyBorder: false
        });
        
        new Ext.Panel({
            hideBorders: true,
            scope: this,
            items: [this.RadioButton,this.ChartsButton,this.ChartsView, this.myBoxButton,this.myBoxView, this.myAlbums, this.panelMenuOpening],
            renderTo: this.zoneMenu,
            bodyBorder: false,
            ctCls: "accountMenu-music"
        });
        
        this.subscribeButton = new Ext.Button({
            iconCls: "account-item-subscribe",
            cls: 'x-btn-text-icon',
            text: tr('mainMenu-signup'),
            handler: this.controller.popupSubscribe,
            scope: this
        });
        
        var menu = new Ext.menu.Menu({
            id: 'mainMenu',
            width: 120,
            items: [{
            	text: tr('change_email'),
                handler: this.controller.popupEmail,
                scope: this
            },{
            	text: tr('change_notification'),
                handler: this.controller.popupNotification,
                scope: this
            },{
            	text: tr('change_password'),
                handler: this.controller.popupPassword,
                scope: this
            }, {
            	text: tr('change_username'),
                handler: this.controller.popupUsername,
                scope: this
            },  {
                text: tr('header_disconnect'),
                handler: this.controller.logout,
                scope: this
            }]
        });
        
        
        /*
         * openfire
         * {
         *		text: 'Ketby',
         *		handler: function(){},
         *		scope:this,
         *		icon : 'http://tamtam.jiwa:9090/plugins/presence/status?jid=ketby@openfire.jiwa&type=image'
         *	},
         */
        
        
        this.accountButton = new Ext.Button({
            iconCls: "account-item-connect",
            cls: 'x-btn-text-icon',
            text: tr('my_account'),
            menu: menu,
            scope: this
        });
        
        this.connectButton = new Ext.Button({
            iconCls: "account-item-connect",
            cls: 'x-btn-text-icon',
            text: tr('header_connect'),
            handler: this.controller.popupLogin,
            scope: this
        });
        
     
        
        
        this.myMails = new Ext.Button({
            cls: "account-item-mail",
            width: 60,
            text: ""
        });
        
        //J.statusBar.addSeparator();
        //J.statusBar.addItem(this.myFriendsList);
		
        this.subscribeSeparator = J.statusBar.addSeparator();
        J.statusBar.addItem(this.subscribeButton);
        this.mailSeparator = J.statusBar.addSeparator();
        J.statusBar.addItem(this.myMails);
        J.statusBar.addSeparator();
        J.statusBar.addItem(this.accountButton);
        this.connectSeparator = J.statusBar.addSeparator();
        J.statusBar.addItem(this.connectButton);
		J.statusBar.addSeparator();
        this.connectSeparator.hide();
        this.mailSeparator.hide();
        this.accountButton.hide();
        this.myMails.hide();
    }/*,
    refreshFriendList: function(data){
    
        this.FriendListMenu.removeAll();
        
        var nbrFriendConnected = 0;
        
        Ext.each(data.friends, function(user, userIndex){
            if (user.connected != "Unavailable") {
                nbrFriendConnected++;
                this.FriendListMenu.addMenuItem({
                    text: user.userName,
                    handler: function(){
                        J.fc.getController('openfire', true).openWindow(user);
                    },
                    scope: this,
                    icon: 'http://tamtam.jiwa:9090/plugins/presence/status?jid=' + user.userName + '@openfire.jiwa&type=image'
                });
            }
        }, this);
        
        if (nbrFriendConnected == 0) {
            this.FriendListMenu.addMenuItem({
                text: 'Aucun connecté',
                handler: function(){
                },
                scope: this,
                icon: 'http://tamtam.jiwa:9090/plugins/presence/status?jid=@openfire.jiwa&type=image'
            });
        }
        
        if (nbrFriendConnected < 2) {
            this.myFriendsList.setText('Ami connecté (' + nbrFriendConnected + ')');
        }
        else {
            this.myFriendsList.setText('Amis connectés (' + nbrFriendConnected + ')');
        }
    }*/,
    refreshAccountButton: function(){
    
        if (this.controller.model.loggedIn) {
        
            this.connectButton.hide();
            
            this.subscribeButton.setText(J.me.getField('userName'));
            this.subscribeButton.setHandler(function(){
                J.fc.gotoUrl("user", J.me.userId);
            }, this);
            
            
            this.mailSeparator.show();
            this.connectSeparator.hide();
            J.fc.getController('mainMenu', true).hideConnect();
            
            this.accountButton.show();
            this.myMails.show();
            this.myMails.setText('');
            this.myMails.setHandler(function(){
                J.fc.gotoUrl('account', 'mails')
            }, this);
            
        }
        
    },
    
    refreshPlaylistsList: function(){
    
        Ext.get('playlists-items').update('');
        
        this.myPlaylistsView = new Ext.tree.TreePanel({
            rootVisible: false,
            border: false,
            el: 'playlists-items',
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            enableDD: true,
            containerScroll: false,
            root: this.controller.model.playlistsTreeNode,
            draggable: true,
			listeners:{
				 scope:this,
				 beforemovenode :function( tree, node, oldParent, newParent, index){
					this.controller.model.updatePlaylistPosition({
						playlistId:node.attributes.href.split("/")[1],
						position:index,
						parentNode:newParent.text
					});			
				}
			}
        });
        
        this.myPlaylistsView.render();
        this.controller.model.playlistsTreeNode.expand();
        
    },
    
    refreshRadioSubscriptionsList: function(){
    
        Ext.get('subscriptions-radios').update('');
        
        this.myRadioSubscriptionsView = new Ext.tree.TreePanel({
            rootVisible: true,
            border: false,
            el: 'subscriptions-radios',
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            enableDD: false,
            containerScroll: false,
            root: this.controller.model.radioSubscriptionsTreeNode
        });
        
        this.myRadioSubscriptionsView.render();
        
        
    },
    refreshArtistSubscriptionsList: function(){
    
        Ext.get('subscriptions-artists').update('');
        
        if (J.me.isLoggedIn()) {
            this.myPlayListContent.expand();
        }
        
        this.myArtistSubscriptionsView = new Ext.tree.TreePanel({
            rootVisible: true,
            border: false,
            el: 'subscriptions-artists',
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            enableDD: false,
            containerScroll: false,
            root: this.controller.model.artistSubscriptionsTreeNode
        });
        
        this.myArtistSubscriptionsView.render();
        
        
    },
    refreshAngelSubscriptionsList: function(){
    
        Ext.get('subscriptions-angels').update('');
        
        this.myAngelSubscriptionsView = new Ext.tree.TreePanel({
            rootVisible: true,
            border: false,
            el: 'subscriptions-angels',
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            enableDD: false,
            containerScroll: false,
            root: this.controller.model.angelSubscriptionsTreeNode
        });
        
        this.myAngelSubscriptionsView.render();
        
        
    },
    getContentBody: function(){
    
        this.body = this.panel.body.child("#detail-col-body");
        this.body.update("");
        return this.body.createChild({});
    },
    renderCard: function(){
    
        this.zone = J.fc.getZone("content");
        
        if (this.panel) {
            this.panel.destroy();
        }
        
        this.panel = new Ext.Panel({
            cls: "detail",
            renderTo: this.zone,
            border: false,
            html: '<table cellpadding=0 cellspacing=0 width="100%">' +
            '<tr><td width="681">' +
            
            '<table cellpadding=0 cellspacing=0 class="detail-header">' +
            '<tr>' +
            '<td class="detail-header-left">' +
            '</td>' +
            '<td class="detail-header-title" ><table width="100%"><tr><td idth="100%" id ="detail-header-title"></td ><td  id ="detail-header-msg"></td></tr></table></td>' +
            '<td class="detail-header-right">' +
            '</td>' +
            '</tr>' +
            '</table>' +
            
            '</td>' +
            '<td>' +
            '</td>' +
            
            '</tr>' +
            
            '<tr><td>' +
            '</td>' +
            '<td>' +
            '</td>' +
            
            '</tr>' +
            // separator
            
            // content
            '<tr id="detail-row-bottom">' +
            
            '<td id="detail-col-bodyWrapper" >' +
            '<div id="detail-col-title" class ="body-title">' +
            '</div>' +
            '<div id="detail-col-body">' +
            '</div>' +
            '</td>' +
            '<td id="detail-col-categoriesWrapper">' +
            '</td>' +
            '</tr>' +
            
            
            '<tr>' +
            
            '<td>' +
            // footer
            '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
            '<tr>' +
            '<td class="detail-footer-left">' +
            '</td>' +
            '<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
            tr("gotoupperPage") +
            '</td>' +
            '<td class="detail-footer-right">' +
            '</td>' +
            
            '</tr>' +
            '</table>' +
            
            '</td>' +
            '<td >' +
            '</td>' +
            '</tr>' +
            '</table>'
        
        
        });
        
        this.titleEl = Ext.get("detail-header-title");
        
        
    },
    renderMailBox: function(body, options){
    
        this.zone = J.fc.getZone("content");
        
        if (this.panel) {
            this.panel.destroy();
        }
        
        this.panel = new Ext.Panel({
            cls: "detail",
            renderTo: this.zone,
            border: false,
            html: '<table cellpadding=0 cellspacing=0 width="100%">' +
            '<tr><td width="681">' +
            
            '<table cellpadding=0 cellspacing=0 class="detail-header">' +
            '<tr>' +
            '<td class="detail-header-left">' +
            '</td>' +
            '<td class="detail-header-title" ><table width="100%"><tr><td idth="100%" id ="detail-header-title"></td ><td  id ="detail-header-msg"></td></tr></table></td>' +
            '<td class="detail-header-right">' +
            '</td>' +
            '</tr>' +
            '</table>' +
            
            '</td>' +
            '<td>' +
            '</td>' +
            
            '</tr>' +
            
            // content
            '<tr id="detail-row-bottom">' +
            
            '<td id="detail-col-bodyWrapper" >' +
            '<div id="detail-col-title" class ="body-title">' +
            '</div>' +
            '<div id="detail-col-body">' +
            '</div>' +
            '</td>' +
            '<td id="detail-col-categoriesWrapper">' +
            '<div class="detail-categories-top"></div>' +
            '<div class="detail-col-categories" id="detail-col-categories"></div>' +
            '<div class="detail-categories-bottom"></div>' +
            '</td>' +
            '</tr>' +
            
            
            '<tr>' +
            
            '<td>' +
            // footer
            '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
            '<tr>' +
            '<td class="detail-footer-left">' +
            '</td>' +
            '<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
            tr("gotoupperPage") +
            '</td>' +
            '<td class="detail-footer-right">' +
            '</td>' +
            
            '</tr>' +
            '</table>' +
            
            '</td>' +
            '<td >' +
            '</td>' +
            '</tr>' +
            '</table>'
        
        
        });
        
        
        this.categoriePanel = new Ext.Panel({
            width: '140',
            renderTo: "detail-col-categories"
        });
        // Categories
        var categoriesRenderTo = this.categoriePanel.body;
        this.categories = {};
        Ext.each(this.options.categories, function(category){
            this.categories[category.id] = new Ext.SimpleButton({
                text: category.text,
                buttonId: category.id,
                renderTo: categoriesRenderTo,
                enableToggle: true,
                toggleGroup: "details-categories",
                toggleHandler: this.categoryHandler,
                scope: this
            });
        }, this);
        
        this.contentEl = Ext.get("detail-col-infos");
        this.titleEl = Ext.get("detail-header-title");
        this.bodyTitle = Ext.get("detail-col-title");
        
    },
    setTitle: function(title){
    
        this.titleEl.update(title);
        
    },
    setActiveCategory: function(buttonId){
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        }
        else 
            if (this.activeButton) {
                this.activeButton.toggle(false);
            }
    },
    
    /**
     * Toggle handler of the categories (on the left)
     * @param {Object} button
     * @param {Boolean} state
     */
    categoryHandler: function(button, state){
        if (state) {
            this.setActiveCategory(button.buttonId);
            J.fc.gotoUrl("account", "mails", button.buttonId)
        }
    },
    // ========================================================================
    onSubmit: function(){
        if (this.FormPanel && this.FormPanel.form.isValid()) {
            this.FormPanel.form.submit({
                waitMsg: tr('newMail_msg_sending'),
                clientValidation: true,
                success: this.onSuccess,
                failure: this.onFailure,
                scope: this
            });
        }
        else {
            //Ext.MessageBox.alert('Errors', 'Please fix the errors noted.');
        }
    },
    
    renderNewMail: function(body){
    
        this.tbar = null;
        
        this.bbar = null;
        
        this.bodyTitle.update(tr('universe_profile_button_write'));
        
        this.FormPanel = new Ext.FormPanel({
            labelWidth: 100,
            renderTo: body,
            url: 'user/outboxsend',
            border: false,
            frame: false,
            defaults: {
                width: 300
            },
            autoHeight: true,
            items: [new Ext.form.TextField({
                fieldLabel: tr('newMail_label_recipients'),
                name: 'recipientsNames',
                maxLength: 200,
                value: ''
            }), new Ext.form.TextField({
                fieldLabel: tr('newMail_label_subject'),
                name: 'subject',
                maxLength: 100,
                value: ''
            }), new Ext.form.TextArea({
                fieldLabel: tr('newMail_label_body'),
                name: 'body',
                id: 'mailInput',
                height: 150,
                value: ''
            })]
        });
        
        this.mailPanel = new Ext.Panel({
            layout: 'column',
            renderTo: body,
            style: 'padding:10px',
            bodyStyle: 'padding:10px 15px 0;background-color:#f7f7f6;',
            border: false,
            frame: true,
            items: [{
                columnWidth: 1,
                border: false,
                items: [this.FormPanel]
            }, {
                width: 180,
                border: false,
                cls: "button-actions"
            }]
        });
        
        var actionsRenderTo = this.mailPanel.body.child(".button-actions");
        
        var button = actionsRenderTo.createChild({
            html: tr('newMail_button_send')
        });
        
        button.on('click', function(){
            this.onSubmit();
        }, this);
        
        
        var cancel = actionsRenderTo.createChild({
            cls: 'cancel-action',
            html: tr('newMail_button_cancel')
        });
        
        cancel.on('click', function(){
            history.back()
        }, this);
        
        
        Ext.get('mailInput').focus();
        
    },
    renderInbox: function(body, store){
    
    
        this.tbar = null;
        
        this.bbar = null;
        
        /*this.deleteButton = new Ext.Button({
            iconCls: "delete-mail",
            text: tr('mail_button_delete'),
            handler: function(){
                this.controller.deleteMails();
            },
            scope: this
        });*/
        
        this.seeReadedButton = new Ext.Button({
            iconCls: "read-mail",
            text: tr('read')
        });
        
        this.seeNotreadedButton = new Ext.Button({
            iconCls: "noread-mail",
            text: tr('unread')
        });
        
        
        this.bodyTitle.update(tr("inbox"));
        this.tbar = new J.Bar({
            cls: "mail-toolbar",
            defaultText: ''
        });
        
        
        this.MailGrid = new J.View.MailGrid({
            store: store,
            anchor: '100%'
        });
        
        
        this.mailPanel = new Ext.Panel({
            renderTo: body,
            border: false,
            scope: this,
            items: this.MailGrid,
            bbar: this.bbar,
            tbar: this.tbar
        });
        
        this.tbar.left = true;
        this.tbar.addItem(this.seeNotreadedButton);
        this.tbar.addSeparator();
        this.tbar.addItem(this.seeReadedButton);
        
        this.tbar.left = false;
        this.tbar.addSeparator();
        //this.tbar.addItem(this.deleteButton);
        
    },
    renderOutBox: function(body, store){
    
    
        this.tbar = null;
        
        this.bbar = null;
        
        this.seeReadedButton = new Ext.Button({
            iconCls: "read-mail",
            text: tr('read')
        });
        
        this.seeNotreadedButton = new Ext.Button({
            iconCls: "noread-mail",
            text: tr('unread')
        });
        
        this.tbar = new J.Bar({
            cls: "mail-toolbar",
            defaultText: ''
        });
        
        this.bodyTitle.update(tr("msg_send"));
        
        this.MailGrid = new J.View.MailSendGrid({
            store: store,
            anchor: '100%'
        });
        
        this.mailPanel = new Ext.Panel({
            renderTo: body,
            border: false,
            scope: this,
            items: this.MailGrid,
            bbar: this.bbar,
            tbar: this.tbar
        });
        
        this.tbar.left = true;
        this.tbar.addItem(this.seeNotreadedButton);
        this.tbar.addSeparator();
        this.tbar.addItem(this.seeReadedButton);
        
    },
    // ========================================================================
    onSuccess: function(form, action){
        if (action.result.success) {
            J.InfoBox.msg(tr('newMail_alert_sent_msg'));
            history.back();
        }
        else {
            Ext.MessageBox.alert(tr('ERR__ERROR'), action.result.error.statusText);
        }
    },
    
    // ========================================================================
    onFailure: function(form, action){
        Ext.MessageBox.alert(tr('ERR__ERROR'), action.response.statusText);
    },
    refreshPlaylistSubscriptionsList: function(){
    
        Ext.get('subscriptions-playlists').update('');
        
        this.myPlaylistSubscriptionsView = new Ext.tree.TreePanel({
            rootVisible: true,
            border: false,
            el: 'subscriptions-playlists',
            height: 'auto',
            useArrows: true,
            autoScroll: false,
            animate: true,
            enableDD: false,
            containerScroll: false,
            root: this.controller.model.playlistSubscriptionsTreeNode
        });
        
        this.myPlaylistSubscriptionsView.render();
        
        
    },
    renderDownload: function(body){
    
        body.update('');
        
        var header = body.createChild();
        var content = body.createChild();
        
        new Ext.Panel({
            layout: 'column',
            renderTo: header,
            style: 'padding:0px 10px 10px 10px',
            bodyStyle: 'padding:10px 15px 0;background-color:#f7f7f6;',
            border: false,
            frame: true,
            width: 670,
            html: tr('download_description')
        });
        
        
        this.tpl = new Ext.XTemplate('<div class="download-container" >', '<tpl for=".">', '<dd class="item-wrap"  >', '<div class="item-main"  id="{radioUrl}" style="padding-top:4px;">', '<div  onClick="J.fc.gotoUrl(\'track\',\'{trackId}\')" >{albumId:this.albumPictureDownloadRenderer}</div>', '<div class="item-content">', '<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')"class="item-ownerName" style="padding-top:5px;">{artistName}</div>', '<div onClick="J.fc.gotoUrl(\'track\',\'{trackId}\')" class="item-ownerName" style="color:black !important;font-weight:bold;">{songName:this.reduceTitleTrackOnDownloadOP}</div>', '<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-ownerName">{albumName}</div>', '<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" style="margin-top:5px;height:55px" >{trackId:this.descriptionDownload}</div>', '</div>', '</div>', '<div class="item-action">', '<span onClick="J.fc.getController(\'album\',true).play(\'{albumId}\')" class="item-play">' + tr('play') + '</span>', '<tpl if="this.isDownloadable(trackId).granted == true"><span class="item-page" onClick="window.open(\'/user/downloadtrack?trackId={trackId}&languageId=' + J.languageId + '\')">' + tr('player-download') + '</span></tpl>', '<tpl if="this.isDownloadable(trackId).granted == false"><span class="item-page">{trackId:this.getDateDispoForDownload}</span></tpl>', '</div>', '</dd>', '</tpl>', '</div>', J.render);
        
        var store = this.controller.model.getDonwloadsStore();
        this.radioPanel = new Ext.DataView({
            itemSelector: 'dd',
            store: store,
            scope: this,
            loadingText: tr('content_loading'),
            loadMask: true,
            renderTo: content,
            frame: true,
            tpl: this.tpl
        });
        
        
        
    },
    /**
     * Handler of the actions
     * @param {Object} button
     */
    actionHandler: function(nav, el){
        this.controller.actionHandler(el.id);
    },
    options: {
        subs: [{
            id: 'similar-artist-button',
            text: 'card_similar_artist'
        }, {
            id: 'play-button',
            text: 'card_play'
        }, {
            id: 'tools-button',
            text: 'card_tools',
            admin: true
        }],
        categories: [{
            id: "new",
            text: tr('universe_profile_button_write')
        }, {
            id: "inbox",
            text: tr('inbox')
        }, {
            id: "outbox",
            text: tr('msg_send')
        }],
        actions: [{
            id: "message",
            text: tr('universe_profile_button_write')
        }, {
            id: "signal",
            text: tr('problem_header')
        }, {
            id: "permalink",
            text: tr("copy_link")
        }]
    }
});


J.View.Radio = Ext.extend( J.View.Base, {

	render: function(domain) {
		
		if(this.panel){
			this.panel.destroy();
		}
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
			
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title"><span class="head-name-title">'+tr('mainMenu-radio')+'</span></td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td class="top-categorie-header"> Top radios' +
							'</td>' +       	        
	 
					'</tr>' +
					
					
					'<tr >' +
        	        '<td id="radio-spot" class="radio-content">' +
        	        '</td>'+
        	        
								'<td class="top-col" >' +
									'<div class="detail-categories-top"></div>' +
									'<div id="detail-top-Wrapper" class="detail-col-categories" ></div>' +
		        	       		 	'<div class="detail-categories-bottom"></div>' +
	        	        		'</td>'  +
	        	        	
	        	     '</tr>' +

        	        
					'<tr>' +
				
        	        '<td id="radios" >' +
        	        
        	  
							'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							'<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	        	        	'</td>' +
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });

		var body =  Ext.get('radios');

		this.categoriePanel =   new Ext.Panel({
			width:'140',
			renderTo:"detail-col-categories"
		 });	
		
		var store = this.controller.model.getRadiosStore();
		
		var spot = Ext.get('radio-spot');
		
		var content = body.createChild({cls: 'radio-content'});
		
		content.update('');
		
		this.tpl = new Ext.XTemplate(    '<div> <tpl for=".">',
		'<tpl if="radioMain != 0">',
						'</div>',
						'<div class="item-header" >',
							'<div class="item-header-name">',
								'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">{radioName}</span></div>',
							'</div>',
						'</div>',
						'<div class="item-container" ></tpl>',
		        '<dd class="item-wrap"  >',
				
				'<div class="item-main"  id="{radioUrl}">',
						'<div  onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" >{radioId:this.smallRadioPicture}</div>',
			        	'<div class="item-content">',
							'<div onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-name">{radioName}</div>',
							'<div class="item-ownerName"></div>',
							'<div onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-popularity">{radioPopularity:this.popularityRenderer}</div>'+
						'</div>',
					'</div>',
					'<div class="item-action">',
						'<span onClick="J.fc.getController(\'station\',true).play(\'{radioId}\',\'{radioName}\')" class="item-play">'+tr('play')+'</span>',
						'<span onClick="J.fc.getController(\'station\',true).changeSub(\'{radioId}\')" id="item-subscribe-{radioId}" class="item-subscribe">',
						'<tpl if="!this.isFan(radioId)">'+tr('subscribe')+'</tpl>'+
						'<tpl if="this.isFan(radioId)">'+tr('unsubscribe')+'</tpl>'+
						'</span>',
						'<span onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
					'</div>',
				'</dd>',
		    '</tpl>',
			'</div>',J.render);
			
		
			this.tpl.isFan = J.fc.getController('station',true).isFan;
		

		this.radioPanel = new Ext.DataView({
                itemSelector: 'dd',
                store: store,
				loadingText : tr('content_loading'),
				loadMask: true,
				renderTo:content,
                tpl:this.tpl 
            });
		
		
		var top = Ext.get('detail-top-Wrapper');
		
		this.tpl = new Ext.XTemplate(    '<tpl for=".">',
		        '<div onClick="J.fc.getController(\'station\',true).play(\'{radioId}\',\'{radioName}\')" class="top-{[xindex]} top-radio-zone" >',
				'{radioName:this.reduce}',
				'</div>',
		    '</tpl>');
			
			
		this.tpl.reduce = function(value){
		  		return J.render.reduce(value,13);
		  }

		this.radioTopPanel = new Ext.DataView({
                itemSelector: 'dd',
				ads :false,
                store: this.controller.model.getTopRadiosStore(),
                tpl:this.tpl 
            });
		
		var panel = new Ext.Panel({
			renderTo:top,
		    items: this.radioTopPanel
		});
		

		store.on('load',function(){
			this.showMenu(spot, store);
        }, this);
		
		if(store. getTotalCount()>0){
			store.clearFilter(false);
			this.showMenu(spot,store);
		}
	},
	showMenu :function(spot,store){
		
		var categoriesRenderTo = this.categoriePanel.body;
		
		this.spotContent = spot.createChild({cls:"spot-content"});
			
		store.each(function(radio) {
			
			if (!this.AllButton) {
				this.AllButton = new Ext.SimpleButton({
					text: tr('all'),
					renderTo: categoriesRenderTo,
					enableToggle: true,
					toggleGroup: "details-categories",
					toggleHandler: function(button, a, b){
						
						Ext.get("pub-categories").update(this.getAds());
						store.clearFilter(false);
					}
				});
				
			}
			
			
			if(radio.data.radioPromo){
			
			var tpl = new Ext.XTemplate( '<dd class="item-wrap"  >',
					'<div class="item-main  item-80"  id="{radioUrl}">',
						'<div  onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" >{radioId:this.bigRadioPicture}</div>',
			        	'<div class="item-content">',
							'<div onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-name">{radioName}</div>',
							'<div onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-description">{radioDescription:this.midllereduce}</div>',
						'</div>',
					'</div>',
				
					'<div class="item-action">',
						'<span onClick="J.fc.getController(\'station\',true).play(\'{radioId}\',\'{radioName}\')" class="item-play">'+tr('play')+'</span>',
						'<span onClick="J.fc.getController(\'station\',true).changeSub(\'{radioId}\')" id="spot-subscribe-{radioId}" class="item-subscribe">',
						'<tpl if="!this.isFan(radioId)">'+tr('subscribe')+'</tpl>'+
						'<tpl if="this.isFan(radioId)">'+tr('unsubscribe')+'</tpl>'+
						'</span>',
						'<span onClick="J.fc.gotoUrl(\'station\',\'{radioId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
					'</div>',
				'</dd>',J.render);
				
					
				tpl.isFan = J.fc.getController('station',true).isFan;
		
	
    			tpl.overwrite(this.spotContent.createChild(), radio.data);
		

			}
			
			var view = this;
			if(radio.data.radioMain){
				new Ext.SimpleButton({
					text: radio.data.radioName,
					buttonId: radio.data.radioTags,
					renderTo: categoriesRenderTo,
					enableToggle: true,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
		
						if(a){
							Ext.get("pub-categories").update(view.getAds());
							store.filter('radioTags',button.buttonId);
							
						}
					}
				});
				
			}
		
		},this);

	Ext.get("pub-categories").update(this.getAds());
		
	},

    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }

		
    }
});

J.View.Recommendation = Ext.extend( J.View.Base, {

	render: function(domain) {
    	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title"><span class="head-name-title">'+tr('mainMenu-recommendation')+'</span></td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
					'</tr>' +
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
        	        '</tr >' +
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							'<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	        	        '</td>' +
	        	    '</tr>' +
					'<tr>' +
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });
		

	
		this.title = Ext.get("data-title");
		var body =  Ext.get('albums');

		this.categoriePanel =   new Ext.Panel({
			width:'140',
			renderTo:"detail-col-categories"
		 });
			
		var content = body.createChild({cls: 'album-content'});
		
		//
		this.albumPanel = new J.View.AlbumData({
				parent: this,
				anchor:'100%',
                store: this.controller.model.getStore(),
				renderTo: content
			});
		 this.tbar = new Ext.ActionPagingToolbar({
            cls: "contentTopPaging",
			style: 'padding:0px 10px 10px 10px',
            store: this.controller.model.getStore(),
			ActionPaging:false,
			pageSize: 30
        });
		
		this.bbar = new Ext.ActionPagingToolbar({
            cls: "contentBottomPaging",
			style: 'padding:0px 10px 10px 10px',
            store: this.controller.model.getStore(),
			ActionPaging:false,
			pageSize: 30
        });
		
		var panel = new Ext.Panel({
		    autoHeight:true,
			tbar :this.tbar,
			bbar :this.bbar,
		    layout:'fit',
			renderTo:content,
		    items: this.albumPanel
		});
		
		this.categories = [];
		
	var cats = arrTr('themes');
	
	
		var categoriesRenderTo = this.categoriePanel.body;	
		
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categories[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					renderTo: categoriesRenderTo,
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							
							this.title.update('<div class="item-header" ><div class="item-header-name">'+
																			'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">'+ button.text +'</span></div>'+
																		'</div></div></tpl>');
							
							this.albumPanel.store.baseParams ={theme :button.buttonId};
							
							Ext.get("pub-categories").update(this.getAds());
							
							this.albumPanel.store.load();
							
							
							
						}
					}
				});
		
		}
		
		
		this.setActiveCategory('all');
		
		Ext.get("pub-categories").update(this.getAds());
	
	},

    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
		
		Ext.get("pub-categories").update(this.getAds());
    }

});

J.View.Last = Ext.extend( J.View.Base, {

	render: function(domain) {
    	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title"><span class="head-name-title">'+tr('mainMenu-newReleases')+'</span></td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
					'</tr>' +
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
        	        '</tr >' +
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							'<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	        	        '</td>' +
	        	    '</tr>' +
					'<tr>' +
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });
		

	
		this.title = Ext.get("data-title");
		var body =  Ext.get('albums');

		this.categoriePanel =   new Ext.Panel({
			width:'140',
			renderTo:"detail-col-categories"
		 });
			
		var content = body.createChild({cls: 'album-content'});
		
		//
		this.albumPanel = new J.View.AlbumData({
				parent: this,
				anchor:'100%',
                store: this.controller.model.getStore(),
				renderTo: content
			});
		 this.tbar = new Ext.ActionPagingToolbar({
            cls: "contentTopPaging",
			style: 'padding:0px 10px 10px 10px',
            store: this.controller.model.getStore(),
			ActionPaging:false,
			pageSize: 30
        });
		
		this.bbar = new Ext.ActionPagingToolbar({
            cls: "contentBottomPaging",
			style: 'padding:0px 10px 10px 10px',
            store: this.controller.model.getStore(),
			ActionPaging:false,
			pageSize: 30
        });
		
		var panel = new Ext.Panel({
		    autoHeight:true,
			tbar :this.tbar,
			bbar :this.bbar,
		    layout:'fit',
			renderTo:content,
		    items: this.albumPanel
		});
		
		this.categories = [];
		
	var cats = arrTr('themes');
	
	
		var categoriesRenderTo = this.categoriePanel.body;	
		
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categories[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					renderTo: categoriesRenderTo,
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							
							this.title.update('<div class="item-header" ><div class="item-header-name">'+
																			'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">'+ button.text +'</span></div>'+
																		'</div></div></tpl>');
							
							this.albumPanel.store.baseParams ={theme :button.buttonId};
							
							this.albumPanel.store.load();
							Ext.get("pub-categories").update(this.getAds());
						}
					}
				});
		
		}
		
		
		this.setActiveCategory('all');
		
		Ext.get("pub-categories").update(this.getAds());
	
	},

    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
		Ext.get("pub-categories").update(this.getAds());
		
    }

});
/**
 * @author admin
 */

J.View.Top = Ext.extend( J.View.Base, {

	render: function(domain) {
    	
		this.panel = new Ext.Panel({
			cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">' +        	        
					        	        '<span class="head-name-title">'+tr('mainMenu-top')+'</span></td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
	 
					'</tr>' +
					
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
					
					
					
					
									        	        // content
        	        '</tr >' +
					
					
									        	        // content
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	        
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							'<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	        	        '</td>' +
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });
		

	
		this.title = Ext.get("data-title");
		var body =  Ext.get('albums');

		this.categoriePanel =   new Ext.Panel({
			width:'140',
			renderTo:"detail-col-categories"
		 });
			
		 this.content = body.createChild({cls: 'album-content'});
		
		
		
		this.categories = [];
		
		var cats = arrTr('themes');
		
		var categoriesRenderTo = this.categoriePanel.body;	
	
			for(var i in cats) {
			
			var title = cats[i];
		
			this.categories[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					renderTo: categoriesRenderTo,
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							
						this.setContent(button.buttonId,button.text);
						this.button = button;
						}
					}
			});
		
				
		
		}	

		
		this.reload();
	
	},
	setContent :function(buttonId,text){
		
			this.title.update('<div class="item-header" ><div class="item-header-name">' +
			'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">' +
			text +
			'</span></div>' +
			'</div></div></tpl>');
			
			

						
			this.content.update('');
			switch (this.controller.id) {
			
				case 'tracks':{
				
					this.contentPanel = new J.View.TrackGrid({
						store: this.controller.model.getTopSongsStore(buttonId),
						noLoad: true,
						progression: true,
						rank: true,
						style: 'margin-left:5px',
						anchot: '100%',
						scope: this,
						renderTo: this.content
					});
					
				}
break;
				
				default:{
				
					this.tpl = new Ext.XTemplate('<div class="item-container" ><tpl for=".">', '<dd class="item-wrap"  >', '<div class="item-main" id="{playistId}">', '<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" >{playlistId:this.playlistPictureRenderer}</div>', '<div class="item-content">', '<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-name">{playlistName:this.smallText}</div>', '<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-ownerName">{ownerName:this.smallText}</div>', '<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')"class="item-fan">titres: {nbSongs}</div>', '<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-popularity">{playlistPopularity:this.popularityRenderer}</div>' +
					
					'</div>', '</div>', '<div class="item-action">', '<span  onClick="J.fc.getController(\'playlist\',true).play(\'{playlistId}\')" onClick="J.fc.gotoUrl(\'playlistId\',\'{playlistId}\')" class="item-play">' + tr('play') + '</span>', '<span onClick="J.fc.getController(\'playlist\',true).changeSub(\'{playlistId}\')" id="item-subscribe-{playlistId}" class="item-subscribe">', '<tpl if="!this.isFan(playlistId)">' + tr('subscribe') + '</tpl>' +
					'<tpl if="this.isFan(playlistId)">' +
					tr('unsubscribe') +
					'</tpl>' +
					'</span>', '<span onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-page">' + tr('acces_to_card') + '</span>', '</div>', '</dd>', '</tpl>', '</div>', J.render);
					
					this.tpl.playlistPictureRenderer = J.render.playlistPictureRenderer;
					
					this.tpl.isFan = J.fc.getController('playlist', true).isFan;
					
					var store = this.controller.model.getTopPlaylistsStore(buttonId);
					this.topPanel = new Ext.DataView({
						itemSelector: 'dd',
						loadingText: tr('content_loading'),
						loadMask: true,
						tpl: this.tpl,
						store: store
					});
					
					this.contentPanel = new Ext.Panel({
						autoHeight: true,
						layout: 'fit',
						scope: this,
						renderTo: this.content,
						items: this.topPanel
					});
					
					
				}
break;
				
				case 'artists':{

this.tpl = new Ext.XTemplate('<div class="item-container" ><tpl for=".">', '<dd class="item-wrap"  >',
 '<div class="item-main" id="{artistId}">',
  '<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')"  >{artistId:this.artistPictureRenderer}</div>', '<div class="item-content">', 
  '<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-name">{artistName:this.smallText}</div>',
   '<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-popularity">{artistPopularity:this.popularityRenderer}</div>' +
  	'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-name">{progression:this.progressionRenderer}</div>',
   				
					'</div>', '</div>', '<div class="item-action">', '<span  onClick="J.fc.getController(\'artist\',true).play(\'{artistId}\',\'{artistName}\')" class="item-play">' + tr('play') + '</span>', '<span onClick="J.fc.getController(\'artist\',true).changeSub(\'{artistId}\')" id="item-subscribe-{artistId}" class="item-subscribe">', '<tpl if="!this.isFan(artistId)">' + tr('subscribe') + '</tpl>' +
					'<tpl if="this.isFan(artistId)">' +
					tr('unsubscribe') +
					'</tpl>' +
					'</span>', '<span onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-page">' + tr('acces_to_card') + '</span>', '</div>', '</dd>', '</tpl>', '</div>', J.render);
					
					
					
					this.tpl.isFan = J.fc.getController('artist', true).isFan;
					
					var store = this.controller.model.getTopArtistsStore(buttonId);
					this.topPanel = new Ext.DataView({
						itemSelector: 'dd',
						loadingText: tr('content_loading'),
						loadMask: true,
						tpl: this.tpl,
						store: store
					});
					
					this.contentPanel = new Ext.Panel({
						autoHeight: true,
						layout: 'fit',
						scope: this,
						renderTo: this.content,
						items: this.topPanel
					});


				}
break;
				
				case 'albums':{
					
						this.tpl = new Ext.XTemplate(     '<div class="item-container" ><tpl for=".">',
		'',
		        '<dd class="item-wrap"  >',
				
				'<div class="item-main"  id="{albumId}">',
						'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')"  > {albumId:this.albumPictureRenderer}</div>',
			        	'<div class="item-content">',
							'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-name">{albumName:this.smallText} </div>',
							'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-ownerName">{artistName:this.smallText}</div>',
							'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-name"> {progression:this.progressionRenderer}</div>',
							'</div>',
					'</div>',
					'<div class="item-action">',
						'<span  onClick="J.fc.getController(\'album\',true).play(\'{albumId}\')"  class="item-play">'+tr('play')+'</span>',
						'<span onClick="J.fc.getController(\'album\',true).changeSub(\'{albumId}\')" id="item-subscribe-{albumId}" class="item-subscribe">',
						'<tpl if="!this.isFan(albumId)">'+tr('subscribe')+'</tpl>'+
						'<tpl if="this.isFan(albumId)">'+tr('unsubscribe')+'</tpl>'+
						'</span>',
						'<span onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
					'</div>',
				'</dd>',
		    '</tpl>',
			'</div>',J.render);
			
			this.tpl.isFan = J.fc.getController('album',true).isFan;
			
			
			var store = this.controller.model.getTopAlbumsStore(buttonId);
					this.topPanel = new Ext.DataView({
						itemSelector: 'dd',
						loadingText: tr('content_loading'),
						loadMask: true,
						tpl: this.tpl,
						store: store
					});
					
					this.contentPanel = new Ext.Panel({
						autoHeight: true,
						layout: 'fit',
						scope: this,
						renderTo: this.content,
						items: this.topPanel
					});
				
				}
break;
				
				case 'users':{
					this.tpl = new Ext.XTemplate('<div class="item-container" ><tpl for=".">', '<dd class="item-wrap"  >', '<div class="item-main" id="{userId}">', '<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')"  >{userPicture:this.pictureRenderer}</div>', '<div class="item-content">', '<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-name">{userName:this.smallText}</div>', '<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-popularity">{userPopularity:this.popularityRenderer}</div>' +
					'</div>', '</div>', '<div class="item-action">', '<span  onClick="J.fc.getController(\'user\',true).play(\'{userId}\',\'{userName}\')" class="item-play">' + tr('play') + '</span>', '<span onClick="J.fc.getController(\'user\',true).changeSub(\'{userId}\')" id="item-subscribe-{userId}" class="item-subscribe">', '<tpl if="!this.isFan(userId)">' + tr('subscribe') + '</tpl>' +
					'<tpl if="this.isFan(userId)">' +
					tr('unsubscribe') +
					'</tpl>' +
					'</span>', '<span onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-page">' + tr('acces_to_card') + '</span>', '</div>', '</dd>', '</tpl>', '</div>', J.render);
					
					
					
					this.tpl.isFan = J.fc.getController('user', true).isFan;
					
					var store = this.controller.model.getTopUsersStore(buttonId);
					this.topPanel = new Ext.DataView({
						itemSelector: 'dd',
						loadingText: tr('content_loading'),
						loadMask: true,
						tpl: this.tpl,
						store: store
					});
					
					this.contentPanel = new Ext.Panel({
						autoHeight: true,
						layout: 'fit',
						scope: this,
						renderTo: this.content,
						items: this.topPanel
					});
					
					
				}
break;
				
			}
			
			
							Ext.get("pub-categories").update(this.getAds());
			
	},
	reload : function(){
		
		Ext.get("pub-categories").update(this.getAds());
		if (this.button) {
			this.setContent(this.button.buttonId, this.button.text);
		}else{
			this.setContent(this.categories['all'].buttonId, this.categories['all'].text);
		}
		
		
			
	}
});

J.View.Results = Ext.extend( J.View.Base, {

	menu:{
		normal:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		},
		admin:{
			'tracks':[
					{
					text: tr('play'),
					handler: function(){
						
						J.fc.grid.addToPlayer(true,null,true);
					}
				},{
					text: tr('enqueue'),
					handler: function(){
						J.fc.grid.addToPlayer(true,null,false);
					}
				},{
					text: tr('addToNewPlaylist'),
					handler: function(){
						J.fc.grid.addToNewPlaylist(true);
					}
				},
				{
					text: tr('addToPlaylist'),
					handler: function(){
						J.fc.grid.addToPlaylist(true);
					}
				}
			]
		}
	},
	render: function() {
		
		if(this.panel){
			this.panel.destroy();
		}
    	this.panel = new Ext.Panel({
            cls: "detail",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="" width="100%">' +
	        	        '<tr><td >' +  
			
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">'+tr('search_result')+'</td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td>' +
							'</td>' +       	        
	 
					'</tr>' +
   
	        	 
						// separator
        	        			
	        	 // content
        	        '<tr id="search-content" class="withPaging">' +
        	        '<td id="search-result">' +
        	        
        	        
	        	        	'</td>' +
							'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories" id="detail-col-categories"></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							'<div class="detail-categories-top"></div>' +
    '<div class="detail-col-categories" id="pub-categories"></div>' +
    '<div class="detail-categories-bottom"></div>' +
	        	        	'</td>' +
	        	        '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
					
    	        
 
        });
		
			 this.categoriePanel =   new Ext.Panel({
				width:'140',
				
				renderTo:"detail-col-categories"
			   });
             // Categories
             var categoriesRenderTo = this.categoriePanel.body;
			var options =  [{
                id: "track",
                text: "Titres"
            },{
                id: "album",
                text: "Albums"
            },{
                id: "artist",
                text: "Artist"
            },{
                id: "user",
                text: "Jiwers"
            },{
                id: "playlist",
                text: "Playlists"
            }
			];
			 
             this.categories = {};
             Ext.each(options, function(category) {
                 this.categories[category.id] = new Ext.SimpleButton({
                     text: category.text,
                     buttonId: category.id,
                     renderTo: categoriesRenderTo,
                     enableToggle: true,
                     toggleGroup: "details-categories",
                     toggleHandler: this.categoryHandler,
                     scope: this
                 });
             }, this);
			
			this.body =  Ext.get('search-result');
		
		
	},
	renderResults: function(domain,store) {

		
		this.body.update('');
		if (domain == "track") {
        		
				this.grid = new J.View.TrackGrid({
					store: store,
					
								anchor:'100%',
					renderTo: this.body
				});
					
		} else if (domain== "user") {
						this.grid =new J.View.UserGrid({
								store: store,
								anchor:'100%',
								renderTo: this.body
							});
						
		} else if (domain == "playlist") {
			
			this.grid =new J.View.PlaylistGrid({
								store: store,
								anchor:'100%',
								renderTo: this.body
				});
			
		 } else if (domain == "album") {
			
			this.grid =new J.View.AlbumGrid({
								store: store,
								anchor:'100%',
								renderTo: this.body
				});
			
		 } else if (domain == "artist") {
			
			this.grid =new J.View.ArtistGrid({
								store: store,
								anchor:'100%',
								renderTo: this.body
				});
			
		 }
		 
		 
							Ext.get("pub-categories").update(this.getAds());
	
	},

	categoryHandler: function(button,a,b) {
		
		Ext.get("pub-categories").update(this.getAds());
		
		if(a){
			J.fc.gotoUrl('search',button.buttonId,this.controller.baseParams);
		}
		
		
			
	},

    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
			
            button.toggle(true);
			  
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
		
		
    }

});

J.View.Community = Ext.extend( J.View.Base, {

	cat:'suggestion',
	
	render: function(domain) {
		
    	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
			
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">'+
											'<span class="head-name-title">'+tr('mainMenu-community')+'</span>'+
										'</td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
	 
					'</tr>' +
					
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
					
					
					
					
									        	        // content
        	        '</tr >' +
					
					
									        	        // content
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	        
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +
						
						'<table id="details-categories" cellspacing="0"><tr >' +
							'<td class="top-categorie-header">' +
							'Music Box</td>' +
							'</tr><tr>'+
							'<td>' +
							
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-suggestion" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							
							
							'</td>' +
							'</tr>' +
							'<tr >' +
							'<td class="top-categorie-header">' +
							'Playlists</td>' +
							'</tr><tr>'+
							'<td>' +
							
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-playlist" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
							
							
							
							'</td>' +
							'</tr>' +
							'<tr >' +
							'<td class="top-categorie-header">' +
							'Jiwers</td>' +
							'</tr><tr>'+
							'<td>' +
							
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-user" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +

		'<div class="detail-categories-top"></div>' +
	    '<div class="detail-col-categories" id="pub-categories"></div>' +
	    '<div class="detail-categories-bottom"></div>' +
							
							'</td>' +
							'</tr>' +
							'</table>'+
							
	        	        '</td>' +
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });

		this.title = Ext.get("data-title");

		var body =  Ext.get('albums');

		this.content = body.createChild({cls: 'album-content'});
		
		this.categoriesSuggestion = [];
		this.categoriesUser = [];
		this.categoriesPlaylist = [];
		
		var cats = {lastsuggestion :tr("last_suggestion")};
	
		
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categoriesSuggestion[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					renderTo:"detail-col-suggestion",
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							this.content.update('');
							this.cat ='suggestion';
							
							var store = this.controller.model.getCommunitySongsStore(button.buttonId);
								
							this.contentPanel = new J.View.SuggestionGrid({
						store: store,
						noLoad:true,
						renderTo: this.content,
						scope:this
					});
					
				
									
							this.title.update('<div class="item-header" ><div class="item-header-name">'+
																			'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">'+ button.text +'</span></div>'+
																		'</div></div></tpl>');

						}
					}
				});
		
		}
		
		
		var cats = arrTr('bestUsers_categories');
		
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categoriesUser[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					
					renderTo:"detail-col-user",
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							this.content.update('');
							this.cat ='user';
							
							this.tpl = new Ext.XTemplate(    '<div class="item-container" ><tpl for=".">',
									'<dd class="item-wrap"  >',
										'<div class="item-main" id="{userId}">',
												'<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')"  >{userPicture:this.pictureRenderer}</div>',
									        	'<div class="item-content">',
													'<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-name">{userName:this.smallText}</div>',
													'<div onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-popularity">{userPopularity:this.popularityRenderer}</div>'+
												'</div>',
											'</div>',
											'<div class="item-action">',
												'<span  onClick="J.fc.getController(\'user\',true).play(\'{userId}\',\'{userName}\')" class="item-play">'+tr('play')+'</span>',
												'<span onClick="J.fc.getController(\'user\',true).changeSub(\'{userId}\')" id="item-subscribe-{userId}" class="item-subscribe">',
												'<tpl if="!this.isFan(userId)">'+tr('subscribe')+'</tpl>'+
												'<tpl if="this.isFan(userId)">'+tr('unsubscribe')+'</tpl>'+
												'</span>',
												'<span onClick="J.fc.gotoUrl(\'user\',\'{userId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
											'</div>',
										'</dd>',
								    '</tpl>',
			'</div>',J.render);
									
								
									
									this.tpl.isFan = J.fc.getController('user',true).isFan;
									
									var store = this.controller.model.getCommunityUsersStore(button.buttonId);
									this.topPanel = new Ext.DataView({
						                itemSelector: 'dd',
										loadingText : tr('content_loading'),
										loadMask: true,
						                tpl:this.tpl ,
										store :store
						            });
								
								this.contentPanel = new Ext.Panel({
								    autoHeight:true,
								    layout:'fit',
									scope:this,
					                 renderTo: this.content,
								    items: this.topPanel
								});
							
							this.title.update('<div class="item-header" ><div class="item-header-name">'+
																			'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">'+ button.text +'</span></div>'+
																		'</div></div></tpl>');
						
						
						}
					}
				});
		
		}
		
		
		
		var cats = arrTr('bestPlaylists_categories');
		

		
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categoriesPlaylist[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
					renderTo:"detail-col-playlist",
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						
						
						if(a){
							this.cat ='playlist';
							
							this.content.update('');
							this.tpl = new Ext.XTemplate(    '<div class="item-container" ><tpl for=".">',
									'<dd class="item-wrap"  >',
										'<div class="item-main" id="{playistId}">',
												'<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" >{playlistId:this.playlistPictureRenderer}</div>',
									        	'<div class="item-content">',
													'<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-name">{playlistName:this.smallText}</div>',
													'<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-ownerName">{ownerName:this.smallText}</div>',
													'<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')"class="item-fan">titres: {nbSongs}</div>',
													'<div onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-popularity">{playlistPopularity:this.popularityRenderer}</div>'+
						
												'</div>',
											'</div>',
											'<div class="item-action">',
												'<span  onClick="J.fc.getController(\'playlist\',true).play(\'{playlistId}\')" onClick="J.fc.gotoUrl(\'playlistId\',\'{playlistId}\')" class="item-play">'+tr('play')+'</span>',
												'<span onClick="J.fc.getController(\'playlist\',true).changeSub(\'{playlistId}\')" id="item-subscribe-{playlistId}" class="item-subscribe">',
												'<tpl if="!this.isFan(playlistId)">'+tr('subscribe')+'</tpl>'+
												'<tpl if="this.isFan(playlistId)">'+tr('unsubscribe')+'</tpl>'+
												'</span>',
												'<span onClick="J.fc.gotoUrl(\'playlist\',\'{playlistId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
											'</div>',
										'</dd>',
								    '</tpl>',
			'</div>',J.render);
									
								this.tpl.playlistPictureRenderer = J.render.playlistPictureRenderer;
									
								this.tpl.isFan = J.fc.getController('playlist',true).isFan;
								
								var store = this.controller.model.getCommunityPlaylistsStore(button.buttonId);
								this.topPanel = new Ext.DataView({
						                itemSelector: 'dd',
										loadingText : tr('content_loading'),
										loadMask: true,
						                tpl:this.tpl ,
										store :store
						            });
								
								this.contentPanel = new Ext.Panel({
								    autoHeight:true,
								    layout:'fit',
									scope:this,
					                 renderTo: this.content,
								    items: this.topPanel
								});
							
								this.title.update('<div class="item-header" ><div class="item-header-name">'+
																				'<div class="head-name-cardview-radio"><span class="head-name-cardview-title">'+ button.text +'</span></div>'+
																			'</div></div></tpl>');
						
						
						}
					}
				});
		
		}
		
		this.setActiveCategory('lastsuggestion');
		
		
							Ext.get("pub-categories").update(this.getAds());
	},

    setActiveCategory: function(buttonId) {
		var cat = this.cat;
		
		switch(this.cat){
			case "user" :
			 var button = this.categoriesUser[buttonId];
			
			break;
			case "playlist" :
			 var button = this.categoriesPlaylist[buttonId];
			break;
			
			case "suggestion" :
			 var button = this.categoriesSuggestion[buttonId];
			break;
			
		}
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
	
		Ext.get("pub-categories").update(this.getAds());
    }

});
J.View.AlbumData = Ext.extend(Ext.DataView, {

	 constructor: function(p){
    
       	this.tpl = new Ext.XTemplate('<div class="item-container" ><tpl for=".">',
		'',
		        '<dd class="item-wrap"  >',
				'<div class="item-main"  id="{albumId}">',
						'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')"  > {albumId:this.albumPictureRenderer}</div>',
			        	'<div class="item-content">',
							'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-name">{albumName:this.smallText}</div>',
							'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-ownerName">{artistName:this.smallText}</div>',
							'<div onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-popularity">{albumPopularity:this.popularityRenderer}</div>'+
						'</div>',
					'</div>',
					'<div class="item-action">',
						'<span  onClick="J.fc.getController(\'album\',true).play(\'{albumId}\')"  class="item-play">'+tr('play')+'</span>',
						'<span onClick="J.fc.getController(\'album\',true).changeSub(\'{albumId}\')" id="item-subscribe-{albumId}" class="item-subscribe">',
						'<tpl if="!this.isFan(albumId)">'+tr('subscribe')+'</tpl>'+
						'<tpl if="this.isFan(albumId)">'+tr('unsubscribe')+'</tpl>'+
						'</span>',
						'<span onClick="J.fc.gotoUrl(\'album\',\'{albumId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
					'</div>',
				'</dd>',
		    '</tpl>',
			'</div>',J.render);
			
			this.tpl.isFan = J.fc.getController('album',true).isFan;
		
        
        /*************************************/
        
        
        
		
		var baseP = {
            tpl: this.tpl,
            itemSelector: 'dd',
            loadingText: tr('content_loading'),
            loadMask: true,
			autoHeight :true,
            renderTo: p.renderTo
        };
		
		 for (var i in p) {
            baseP[i] = p[i];
        }
		
		baseP.cls = "albumData " + baseP.cls;
        J.View.Comment.superclass.constructor.call(this, baseP);
       
	
    }
});
J.View.ArtistData = Ext.extend(Ext.DataView, {

	 constructor: function(p){
    
       	this.tpl = new Ext.XTemplate(     '<div class="item-container" ><tpl for=".">',
		'',
		        '<dd class="item-wrap"  >',
				'<div class="item-main"  id="{artistId}">',
						'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')"  > {artistId:this.artistPictureRenderer}</div>',
			        	'<div class="item-content">',
							'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-name">{artistName:this.smallText}</div>',
							'<div onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-popularity">{artistPopularity:this.popularityRenderer}</div>'+
						'</div>',
					'</div>',
					'<div class="item-action">',
						'<span  onClick="J.fc.getController(\'artist\',true).play(\'{artistId}\')"  class="item-play">'+tr('play')+'</span>',
						'<span onClick="J.fc.getController(\'artist\',true).changeSub(\'{artistId}\')" id="item-subscribe-{artistId}" class="item-subscribe">',
						'<tpl if="!this.isFan(artistId)">'+tr('subscribe')+'</tpl>'+
						'<tpl if="this.isFan(artistId)">'+tr('unsubscribe')+'</tpl>'+
						'</span>',
						'<span onClick="J.fc.gotoUrl(\'artist\',\'{artistId}\')" class="item-page">'+tr('acces_to_card')+'</span>',
					'</div>',
				'</dd>',
		    '</tpl>',
			'</div>',J.render);
			
			this.tpl.isFan = J.fc.getController('artist',true).isFan;
		
        
        /*************************************/
        
        
        
		
		var baseP = {
            tpl: this.tpl,
            itemSelector: 'dd',
            loadingText: tr('content_loading'),
            loadMask: true,
			autoHeight :true,
            renderTo: p.renderTo
        };
		
		 for (var i in p) {
            baseP[i] = p[i];
        }
		
		baseP.cls = "artistData " + baseP.cls;
        J.View.Comment.superclass.constructor.call(this, baseP);
       
	
    }
});
J.View.AdminBoxes = Ext.extend(J.View.Base, {

    render: function(home){
    
		
        if (this.panel) {
            this.panel.destroy();
        }
        
        if (home) {
			this.home = home;
			if(home.items){
			this.panel = new Ext.ux.MainPortal(home);
					return;
			}
	 	
		}
		
		this.panel = new Ext.ux.MainPortal({
            renderTo: 'zone-content',
			id:'adminPortal',
            title: 'admin Home',
            items : [ { 
				xtype: 'panel',
				frame : true,
				title:' ',
				cls:'white',
			 	columnWidth: 1,
				items :{
						xtype: 'portal',
						items: {
							xtype: 'portalcolumn',
							columnWidth: 1,
							id: 'MainCol'
						}
					}
			},{ 
				xtype: 'panel',
			 	width:315,
				items :[
				{
					"xtype": "adportlet",
					"data": {
						"type": "12",
						"color": "media",
						"icones": "-",
						"format": "5",
						"maxItems": "1",
						"newsIds": "",
						"title": "Publicit\u00e9"
					}
				}
				, {
					xtype: 'panel',
					frame: true,
					title:' ',
					cls:'white',
					items: {
						xtype: 'portal',
						items: {
							xtype: 'portalcolumn',
							columnWidth: 1,
							id: 'rightCol'
						}
					}
				}]
			}]
        });
	
    },
	refresh :function(){
	 if (this.panel) {
            this.panel.destroy();
        }
		this.panel = new Ext.ux.MainPortal(this.home);
	}
});

J.View.AdminNews = Ext.extend( J.View.Card, {

	render: function(domain) {
	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">'+'</td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
	 
					'</tr>' +
							
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
					
					
					
					
									        	        // content
        	        '</tr >' +
				
					
					
									        	        // content
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	        
        	 			 '</td>'+
						'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
	        	        '</td>' +
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });
		 	
    	Ext.get("detail-header-title").update('News Admin');

		this.title = Ext.get("data-title");
		var body =  Ext.get('albums');

		this.categoriePanel =   new Ext.Panel({
					width:'140',
					
				renderTo:"detail-col-categories"
				   });
				   
				   
		this.createNewsButton = new Ext.Button({
                    iconCls: "noread-mail",
                    text: 'Créer une News',
                    handler: function(){
                       J.fc.getController('news',true).create();
                    },
                    scope: this
                });
				
		this.rejectedNewsButton = new Ext.Button({
                    iconCls: "read-mail",
                    text: 'Rejeter',
                    handler: function(){
                        J.fc.getController('news',true).RejecteNews();
                    },
                    scope: this
                });
				
		this.validateNewsButton = new Ext.Button({
                    iconCls: "send-mail",
                    text: 'Valider',
                    handler: function(){
                        J.fc.getController('news',true).ValidateNews();
                    },
                    scope: this
                });
				
		this.deleteNewsButton = new Ext.Button({
					iconCls: "delete-mail",
                    text: 'Supprimer',
                    handler: function(){
                        J.fc.getController('news',true).DeleteNews();
                    },
                    scope: this
                });
                
             
        this.tbar = new J.Bar({
                    cls: "mail-toolbar",
                    defaultText: '',
					items :[this.createNewsButton,
					this.validateNewsButton,
					this.rejectedNewsButton,
					this.deleteNewsButton]
                });
                
                
        this.newsPanel = new Ext.Panel({
                    renderTo: body.createChild({cls: 'album-content'}),
                    border: false,
                    scope: this,
                    tbar: this.tbar
                });
				
		this.content = this.newsPanel.body;
	
		this.categories = [];
		
		var cats = arrTr('statusList');
	
		var categoriesRenderTo = this.categoriePanel.body;	
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categories[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
		
					renderTo: categoriesRenderTo,
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							
							this.title.update('<div class="item-header" ><div class="item-header-name">'+button.text+'</div></div></tpl>');
							
							this.content.update('');
							J.fc.grid = new J.View.AdminNewsGrid({
								store: this.controller.model.getSearchStore(button.buttonId),
								renderTo: this.content,
								style:'margin-left:5px',
								width:650
							});
						}
					}
				});
		
		}
		
		this.setActiveCategory(0);
	
	},
    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
		
    }

});

J.View.AdminTradTool = Ext.extend( J.View.Card, {

	render: function(domain) {
	
    	this.panel = new Ext.Panel({
            cls: "radio",
            renderTo: this.zone,
			anchor:'100%',
            border: false ,
			html :  '<table cellpadding=0 cellspacing=0 class="radio" width="100%">' +
	        	        '<tr><td width="681">' +  
						'<table cellpadding=0 cellspacing=0 class="detail-header">' +
				        	        '<tr>' +        	        
					        	        '<td class="detail-header-left">' +'</td>' +           	        
					        	        '<td class="detail-header-title" id ="detail-header-title">'+'</td>' +        	        
					        	        '<td class="detail-header-right">' +'</td>' +         	        
				        	        '</tr>' +
			        	    '</table>'+
							
							'</td>' +
					 		'<td >' +
							'</td>' +       	        
	 
					'</tr>' +
							
					'<tr><td id ="data-title" class="radio-content"></td ><td></td>' +
					
					
					
					
									        	        // content
        	        '</tr >' +
				
					
					
									        	        // content
        	        '<tr  >' +
        	        '<td id="albums" class="radio-content">' +
        	        
        	 			 '</td>'+
						
						'<td id="detail-col-categoriesWrapper">' +
							'<div class="detail-categories-top"></div>' +
							'<div class="detail-col-categories small" id="detail-col-categories" ></div>' +
        	       		 	'<div class="detail-categories-bottom"></div>' +
	        	        '</td>' +
	        	        
	        	    '</tr>' +

        	        
					'<tr>' +
	        	       		
	        	     '<td>' +
        	        // footer
        	        '<table cellpadding=0 cellspacing=0 class="detail-footer">' +
        	        	'<tr>' +
        	        		'<td class="detail-footer-left">' +'</td>' +
        	        		'<td class="detail-footer-center" onclick="J.fc.scrollToTop()">' +
        	        			tr("gotoupperPage") +
        	       			'</td>' +
	        	        	'<td class="detail-footer-right">'+'</td>' +
							
        	        	'</tr>' +
        	        '</table>'   +
					
					'</td>' +
					'<td >' +
	        	        	'</td>' +
        	        	'</tr>' +
        	        '</table>' 
 
        });
		
    	Ext.get("detail-header-title").update('Translation Tools');

		this.title = Ext.get("data-title");
		var body =  Ext.get('albums');
		
		this.categoriePanel =   new Ext.Panel({
			width:'140',
			renderTo:"detail-col-categories"
		});
			   

		this.tb = new Ext.Toolbar({
		    width: 650,
		    height: 25,
		    items: [
				{
					xtype: 'textfield',
		            name: 'searchLabel',
		            emptyText: 'Label',
					enableKeyEvents: true,
					listeners: {
						 scope : this,
						 keyup : function(object,event, c){
						 	var sSearch = object.getValue();
							for (var i in this.categories) {
								if(this.categories[i].pressed == true){
									var iLanguageId = this.categories[i].buttonId;
									break;
								}
							}
							this.content.update('');
							J.fc.grid = new J.View.AdminTradToolGrid({
								store: this.controller.model.search({sSearchLabel:sSearch,iLanguageId:iLanguageId}),
								renderTo: this.content,
								style:'margin-left:5px',
								width:650
							});
							
						 	
						 }
					}
				},
				{xtype: 'tbspacer'},
				{
		            xtype: 'textfield',
		            name: 'searchTranslation',
		            emptyText: 'Translation',
					enableKeyEvents: true,
					listeners: {
						 scope : this,
						 keyup : function(object,event, c){
						 	var sSearch = object.getValue();
							for (var i in this.categories) {
								if(this.categories[i].pressed == true){
									var iLanguageId = this.categories[i].buttonId;
									break;
								}
							}
							this.content.update('');
							J.fc.grid = new J.View.AdminTradToolGrid({
								store: this.controller.model.search({sSearchTranslation:sSearch,iLanguageId:iLanguageId}),
								renderTo: this.content,
								style:'margin-left:5px',
								width:650
							});
							
						 	
						 }
					}
		        },
		
		        '->',
		
		        {
		            text : 'Créer Label',
		            handler : function(){
		        		J.fc.getController('adminTradTool',true).create();
		        	}
		        },
				{xtype: 'tbspacer'},
				{
		            text: 'Valider la traduction',
		            handler : function(){
						J.fc.getController('adminTradTool',true).validate();
		        	}
		        }
		    ]
		});
        this.newsPanel = new Ext.Panel({
            renderTo: body.createChild({cls: 'album-content'}),
            border: false,
            scope: this,
            tbar: this.tb
        });
				
		this.content = this.newsPanel.body;
		
		
		this.categories = [];
		
		var cats = arrTr('LanguageList');
	
		var categoriesRenderTo = this.categoriePanel.body;	
		for(var i in cats) {
			
			var title = cats[i];
		
			this.categories[i]=	new Ext.SimpleButton({
					text: title,
					buttonId: i,
		
					renderTo: categoriesRenderTo,
					enableToggle: true,
					scope:this,
					toggleGroup: "details-categories",
					toggleHandler:  function(button,a,b) {
						if(a){
							
							this.title.update('<div class="item-header" ><div class="item-header-name">'+button.text+'</div></div></tpl>');
							
							this.content.update('');
							J.fc.grid = new J.View.AdminTradToolGrid({
								store: this.controller.model.getTranslations(button.buttonId),
								renderTo: this.content,
								style:'margin-left:5px',
								width:650
							});
						}
					}
				});
		
		}
		
		this.setActiveCategory(J.languageId);
		
	},
    setActiveCategory: function(buttonId) {
        var button = this.categories[buttonId];
        if (button) {
            button.toggle(true);
        } else if (this.activeButton) {
            this.activeButton.toggle(false);
        }
		
    },
	getLanguageIdDisplay: function(){
		for (var i in this.categories) {
			if(this.categories[i].pressed == true){
				return this.categories[i].buttonId;
			}
		}
	}

});


J.Zoning.ContentZoning = function() {
};


J.Zoning.ContentZoning.prototype = {
	NAME: "content",
	SITEWIDTH: 1000,
	ACCOUNTMENUWIDTH: 149,
	SOCIALMENUWIDTH: 122,
	FIXEDMENUHEIGHT: 40,
	LOGOWIDTH: 200,
	ADMEDIUMRECTANGLEWIDTH: 305,
	HEADERHEIGHT: 77,
	BGHEIGHT: 646,
	HASVIEWPORT: true,
	
	getZone: function(zoneName, component) {
		if (component) {
			return Ext.ComponentMgr.get("zone-"+zoneName);
			
		} else {
			var zone = Ext.get("zone-" + zoneName);
			if (!zone) {
				console.warn("Unable to find zone", zoneName);
				return;
			}
			var body = zone.child(".x-panel-body");
			if (body) {
				return body;
			}
		}
	},
	render: function(siteWidth) {


		J.statusBar = new J.Bar({
            id: 'zone-fixedMenu',
			autoShow :true,
			height:44
        });

	
	  J.viewport = new Ext.Viewport({
            layout: 'border',
			monitorResize :true,
			bufferResize : 2000,
			autoDestroy :true,
			hideBorders :true,
			style:"background:#B3AFAE url(/res/img/viewport-topBg.jpg) repeat-x scroll 0 0;",
			id:'viewport-site',
            items: [{
                autoScroll: true,	
                region: 'center',	
				id:"site",			
				hideBorders :true,
                items:
				{
					width:this.SITEWIDTH+20,					
					hideBorders :true,
				
					//style:"margin-left:auto;margin-right:auto;padding-left:10px;background:transparent url(/res/img/center-bg.png) repeat-y scroll",
					style:"margin-left:auto;margin-right:auto;padding-left:10px;background:transparent url() repeat-y scroll",
					items: [{
                        width: this.SITEWIDTH,
						hideBorders :true,
						border:false,
                        items: [ {
                            id: "zone-adMegaBanner"
                        }, {
                            id: "zone-header",
                            layout: "column",
							hideBorders :true,
                            items: [{
                                id: 'zone-logo',
                                width: this.LOGOWIDTH,
								html:'<div id="beta-title">Beta</div>'
                            }, {
								width :800,
                                id: "zone-mainMenu"
                            }]
                        
                        }, {
                            id: "zone-top",
                            layout: "column",
							height :285,                       
							 hideBorders :true,
                            items: [{
                                id: "zone-topSeparatorWest",
                                columnWidth: 0.5,
                                height: 1
                            }, {
                                id: "zone-player",
                                width: 472
                            }, {
                                id: "zone-socialMenu",
                                width: 210,
                                hideMode: "display"
                            }, {
                                id: "zone-adMediumRectangle",
                                hideMode: "display",
                                width: this.ADMEDIUMRECTANGLEWIDTH
                            }, {
                                id: "zone-focus",
                                width: 514,
                                hideMode: "display",
                                hidden: true
                            }, {
                                id: "zone-topSeparatorEast",
                                columnWidth: 0.5,
                                height: 1
                            }]
                        }, {
                            id: "zone-searchbar"
                        }, {
                            id: "zone-main",
                            height: "auto",
                            layout: "column",
							hideBorders :true,
                            items: [{
                                id: "zone-accountMenu",
                                width: this.ACCOUNTMENUWIDTH,
                                fitHeight: true
                            },{
								hideBorders :true,
								fitHeight: true,
                                anchor:'100%',
								items:[{
									id:'zone-search-advanced',
									anchor:'100%'
								}, {
                                id: "zone-content",
                                cls: "zone-content-notHome",
                                fitHeight: true
                                
                            }]
								
								
							}]
                        },{
							hideBorders :true,
							border:false,
                            id: "zone-footer"
                        }]
                 }]
                },
                bbar: J.statusBar
            }]
        });
		
		
		
		

	
	/*	return;
		this.fixedMenu = new Ext.Panel({
			id: "zone-fixedMenu",
			border: false,
			frame: false,
			html: "fixed menu"
			//			renderTo: Ext.getBody()
		});
		
		return;
		this.fixedMenu.setX(Ext.get("zone-site").getX());
		this.fixedMenu.setHeight(this.FIXEDMENUHEIGHT);
		this.fixedMenu.setWidth(this.SITEWIDTH);
		
		
		 this.zones.add("viewport", {
		 layout: "border",
		 items: ["center", "fixedMenu"]
		 });
		 */
		//		this.viewport.doLayout.defer(1, this.viewport);
		//Ext.get("zone-" + "bgWest").setHeight(Ext.get("zone-site").getHeight());
		//Ext.get("zone-" + "bgWest").setHeight(Ext.get("zone-site").getHeight());
		/*
		 this.fixedMenu = Ext.getBody().createChild({
		 id: "zone-fixedMenu",
		 html: "fixed menu"
		 });
		 this.fixedMenu.setX(Ext.get("zone-site").getX());
		 this.fixedMenu.setHeight(this.FIXEDMENUHEIGHT);
		 this.fixedMenu.setWidth(this.SITEWIDTH);
		 */
	},
	
	switchToHome: function() {
		Ext.ComponentMgr.get("zone-socialMenu").hideMode = "display";
		Ext.ComponentMgr.get("zone-socialMenu").hide();
		Ext.ComponentMgr.get("zone-main").doLayout();
	},
	switchToContent: function() {
		Ext.ComponentMgr.get("zone-socialMenu").hideMode = "display";
		Ext.ComponentMgr.get("zone-socialMenu").show();
		Ext.ComponentMgr.get("zone-main").doLayout();
	}
};
J.Language.init();

J.dev = false;
J.ADMIN = false;



Ext.BLANK_IMAGE_URL = "/res/ext/resources/images/default/s.gif";
J.Config = {};
J.Config.URLSEPARATOR = "%t=";
J.LOGENABLED = true;
J.SITEWIDTH = undefined;//"max";
J.MEDIAPATH = "http://medias.jiwa.fm";


Ext.onReady(function(){

    Ext.apply(Ext.QuickTips.getQuickTip(), {
        showDelay: 100
    });
    
    Ext.QuickTips.init(); 
    
    J.InfoBox.init();

    if (!J.fc) {
    
        J.fc = function(){
        
            return {
				PubProfile:{},
                loadingZone: null,
                first: true,
				startrequest :false,
                con: null,
                preview: true,
                playerReady: false,
                grid: null,
                actionButton: null,
                name: "",
				check :false,
				url : null,
                currentSuggestion: "",
                init: function(){
					
					this.controllers = new Ext.util.MixedCollection();
                    // The zoning (skeleton for the site)
                    this.zoning = new J.Zoning.ContentZoning();
                    
                    // Persistant controllers
                    this.controllers.add("ad", new J.Controller.Ad());
                    this.controllers.add("mainMenu", new J.Controller.MainMenu());
                    this.controllers.add("player", new J.Controller.Player());
                    this.controllers.add("search", new J.Controller.Search());
                    this.controllers.add("account", new J.Controller.Account());
                    this.controllers.add("footer", new J.Controller.Footer());
                    this.controllers.add("playlistAdder", new J.Controller.PlaylistAdder());
                  	//  this.controllers.add("openfire", new J.Controller.Openfire());
                    
                    // Content controllers
                   this.controllers.add("home", new J.Controller.Home());
                    this.controllers.add("playlist", new J.Controller.Playlist());
                    this.controllers.add("artist", new J.Controller.Artist());
                    this.controllers.add("track", new J.Controller.Track());
                    this.controllers.add("user", new J.Controller.User());
                    this.controllers.add("radio", new J.Controller.Radio());
                    this.controllers.add("album", new J.Controller.Album());
                    this.controllers.add("station", new J.Controller.Station());
                    this.controllers.add("newReleases", new J.Controller.Last());
                    
                    this.controllers.add("top", new J.Controller.Top());
                    this.controllers.add("recommendation", new J.Controller.Recommendation());
                    this.controllers.add("community", new J.Controller.Community());
					this.controllers.add("mail", new J.Controller.Mail());
                   
				    /* BACKO */
					this.controllers.add("adminNews", new J.Controller.AdminNews());
					this.controllers.add("adminTradTool", new J.Controller.AdminTradTool());
                   	this.controllers.add("adminBoxes", new J.Controller.AdminBoxes());
                    
					/* BACKO-END */
					this.controllers.add("news", new J.Controller.News());
                    this.controllers.add("text", new J.Controller.Text());
                    
                    // Render
                    this.render(J.SITEWIDTH);
                    // this.loadingZone = this.getZone("fixedMenu").createChild({});
                    
                    this.body = Ext.getCmp("site").body;
                    this.content = Ext.getCmp("zone-content");
                    
                    Ext.get('zone-logo').on('click', function(){
                        J.fc.gotoUrl('home');
                    });
                    
                },
                
                multipleRequest: [],
				
                execNextRequest: function(action){
                    //console.log('Nombre d\'element en queue : '+J.fc.multipleRequest.length);
                    if (J.fc.multipleRequest.length == 0) {
                        Ext.Msg.hide();
                        J.fc.store.reload();
                        return;
                    }
					
                    if (J.fc.multipleRequest.length > 0) {
                        var objToDelete = J.fc.multipleRequest.pop();
						if(J.fc.multipleRequest.length == 0){
							objToDelete.lastOccurancy = true;
						}else{
							objToDelete.lastOccurancy = false;
						}
                        var idToDelete = objToDelete.id;
                        var controllerToAction = objToDelete.controller;
                        var methodeToDelete = objToDelete.methode;
                        var tmpController = J.fc.getController(controllerToAction, true);
                        
                        switch (methodeToDelete) {
                            case "reqDelete":
                                tmpController.model.reqDelete(idToDelete);
                                break;
                            case "reqSubscribe":
                                tmpController.model.reqSubscribe(idToDelete);
                                break;
                            case "reqUnSubscribe":
                                tmpController.model.reqUnSubscribe(idToDelete);
                                break;
							case "reqHide":
								tmpController.model.reqHide(idToDelete);
								break;
							case "reqShow":
								tmpController.model.reqShow(idToDelete);
								break;
							case "reqRestrict":
								tmpController.model.reqRestrict(idToDelete);
								break;
							case "reqAllow":
								tmpController.model.reqAllow(idToDelete);
								break;
                            case "delMySuggestions":
								tmpController.model.delMySuggestions(objToDelete);
								break;
							case "delOtherSuggestions":
								tmpController.model.delOtherSuggestions(objToDelete);
								break;
							case "delTranslation":
								tmpController.model.reqDelete(objToDelete);
							
                            default:
                                break;
                        }
                    }
                    
                },
                
                refreshAction: function(){
                    if (this.controller) {
                        this.controller.refreshAction();
                        this.getController("player", true).refreshAction();
                    }
                    
                },
                
                render: function(siteWidth){
                    this.zoning.render(siteWidth);
                    // Init each view

                    this.controllers.each(function(controller){
                        controller.init();
						
                    }, this);
					
					this.removeLoading();
        
					
                },
         	
				 getZone: function(zoneId, wholeZone){
                    return this.zoning.getZone(zoneId, wholeZone);
                },
                trackSearchCallback: function(trackSearch){
                    this.getController("trackSearch").renderResults(trackSearch);
                },
                lastUrl: "",
                initUrl: function(history){
                    var href = top.location.href, i = href.indexOf("#");
                    var token = i >= 0 ? href.substr(i + 1) : null;
                    if (!token) {
                        token = this.gotoUrl("home");
                    }
                    else {
                        this.dispatchUrl(token);
                    }
					
                },
                getController: function(controllerId, keepCurrent){
                
                    var controller = this.controllers.get(controllerId);
                    
                    if (this.controller) {
                        if (controller) {
                            if (controller.baseUrl != "") {
                                if (this.controller.baseUrl == controller.baseUrl) {
                                
                                
                                    return this.controller;
                                }
                            }
                        }
                    }
                    
                    if (controller && (controller != this.controller)) {
                    
                        if (!keepCurrent) {
                        
                            if (this.controller) {
                            
                                if (this.controller.view) {
                                
                                    if (!this.controller.view.renderer) {
                                        this.controller.down();
                                    }
                                    else {
                                    
                                        this.controller.view.rendered = false;
                                        
                                    }
                                    
                                }
                                
                                
                            }
                            
                            this.controller = controller;
                            
                        }
                        
                        
                        
                    }
                    
                    
                    
                    if (controller) {
                        controller.up();
                    }
                    
                    return controller;
                },
                setTitle: function(title){
                    if (title) {
                        document.title = title + ' - Jiwa';
                    }else{
						document.title = 'Jiwa';
					}
                },
                removeLoading: function(){
                    
                    
					 // Init History manager
					Ext.get('loading-mask').remove();
					 	
					Ext.History.init(this.initUrl, this);
                    Ext.History.on('change', this.dispatchUrl, this);
         
					J.fc.setTitle();
					
					
					var cookie = J.CookieProvider.get("ipad-1");
					
					
					if(cookie !='ok'){
						J.fc.getController('user', true).showGame();
					}
					
					
					var restricted = J.CookieProvider.get("restiparicted");
					
					
					if(restricted == false){
						jwPlayer.view.restrictedButton.toggle(false);
					}else{
						
						jwPlayer.view.restrictedButton.toggle(true);
					}	
					
                },
                play: function(){
                    var tracks = arrTr('player_edito_multi_preview');
                 
				  	Ext.each(tracks, function(edito, index){
                        if (edito.track) {
							edito.track.sourceType='home';
                            J.fc.getController("player", true).jwAddTracks([edito.track], {
                                play: false
                            },false);
                        }
                    });
                    
                    this.getController('player', true).preLoadTrackHandler(tracks[0], 0);
                },

                dispatchUrl: function(url){
                    var controller = null;
                    
                    // Refresh ads at each action
                    Ext.History.getToken();
					
					this.url =url;
                    // Refresh ads at each action
                    var menuId = null;
					
					if (url) {
						var p = url.split(J.Config.URLSEPARATOR);
						p = p[0].split("/");
						this.name = p[0];
						
						/*
						 * Check de l'autorisation d'utiliser le mode On-Demand
						 * bUserGrantedAcces dans view/index.php.
						 */
						if (oUserGrantedAccess.granted == false && oUserGrantedAccess.bDisplay == false) {
							J.fc.getController('user', true).popupAccessDenied(oUserGrantedAccess);
							oUserGrantedAccess.bDisplay = true
						//alert("Acces refused");
						}
						
						
						
						
						if (p[0] == "search") {
							controller = this.getController("search");
							controller.search(p[1], Ext.decode(decodeURIComponent(p[2])));
							J.track(p[0], p[1]);
						}
						else 
							if (p[0] == "admin") {
								if (J.me.isLoggedIn() && isStaff()) {
								
									if (p[1] == "news") {
										controller = this.getController("adminNews");
										controller.show(p[2]);
										J.track(p[0]);
									}
									
									if (p[1] == "boxes") {
										controller = this.getController("adminBoxes");
										controller.show(p[2]);
									}
									
									if (p[1] == "trad") {
										controller = this.getController("adminTradTool");
										controller.show(p[2]);
									}
									
								}
								
								
							}
							else 
								if (p[0] == "home") {
									this.getController("home").show();
									menuId = "home";
									J.track(p[0]);
									
								}
							else 
								if (p[0] == "game") {
									J.fc.getController('user', true).showGame();
					
									J.track(p[0]);
									
								}
						else 
									if (p[0] == "reset") {
										if (J.me.isLoggedIn()) {
											//On ouvre le popup de rédéfinition du MDP
											J.fc.getController('account', true).popupPassword();
										}
										//On traite comme si on arrivait sur la home
										this.getController("home").show();
										menuId = "home";
										J.track(p[0]);
									}
									else 
										if (p[0] == "news") {
											if (!J.fc.PubProfile.actu) {
												J.fc.PubProfile.actu=true;
												J.fc.getController('ad', true).getUpdateUrlList();
											}
											this.getController("news").show(p[1], p[2]);
											menuId = "news";
											J.track(p[0]);
										}
										else 
											if (p[0] == "radio") {
												this.getController("radio").show(p[1]);
												menuId = "radio";
												J.track(p[0]);
											}
											else 
												if (p[0] == "playlist") {
													this.getController("playlist").show(p[1], p[2]);
													J.track(p[0], p[2]);
												}
												else 
													if (p[0] == "text") {
														this.getController("text").show(p[1], p[2]);
														J.track(p[0], p[1]);
													}
													else 
														if (p[0] == "station") {
															this.getController("station").show(p[1], p[2]);
															J.track(p[0], p[2]);
														}
														else 
															if (p[0] == "top") {
																this.getController("top").show(p[1], p[2]);
																J.track(p[0], p[1]);
															}
															else 
																if (p[0] == "community") {
																	if (!J.fc.PubProfile.social) {
																		J.fc.PubProfile.social=true;
																		J.fc.getController('ad', true).getUpdateUrlList();
																	}
																	
																	this.getController("community").show(p[1], p[2]);
																	J.track(p[0], p[1]);
																}
																else 
																	if (p[0] == "recommendation") {
																		this.getController("recommendation").show(p[1], p[2]);
																		J.track(p[0], p[1]);
																	}else 
																		if (p[0] == "game") {
																			J.fc.getController('user', true).showGame();
																		}else 
																		if (p[0] == "promo") {
																			J.fc.getController('user', true).showPromo();
																		}else 
																		if (p[0] == "newReleases") {
																			this.getController("newReleases").show(p[1], p[2]);
																			J.track(p[0], p[1]);
																		}
																		else 
																			if (p[0] == "account") {
																			
																				if (J.me.isLoggedIn()) {
																				
																					this.getController("account").show(p[1], p[2], p[3]);
																					J.track(p[0], p[1]);
																					
																				}
																			}
																			else 
																				if (p[0] == "universe" || p[0] == "user") {
																					J.fc.PubProfile.social=true;
																					this.getController("user").show(p[1], p[2]);
																					J.track(p[0], p[2]);
																					
																					
																					
																				}
																				else 
																					if (p[0] == "addict") {
																					
					J.fc.getController('user', true).popupSupporter();
																					}
																				else 
																					if (p[0] == "artist") {
																					
																						this.getController("artist").show(p[1], p[2]);
																						J.track(p[0], p[2]);
																					}
																					else 
																						if (p[0] == "album") {
																							this.getController("album").show(p[1], p[2]);
																							J.track(p[0], p[2]);
																						}
																						else 
																							if (p[0] == "track") {
																							
																								this.getController("track").show(p[1], p[2]);
																								J.track(p[0], p[2]);
																							}
																							else 
																								if (p[0] == "en" || p[0] == "fr") {
																									J.Language.force(p[0]);
																									J.track(p[0]);
																								}
																								else {
																								// console.error("Url not found", url);
																								}
						
						
					}
                    
                    if (this.playerReady && this.first && !this.played) {
						this.played =true;
                        this.play();
						
                    }
				
                    
				
                    J.track('ad', 'content');
                   
				
					if(this.first==true){
						var mask = Ext.get('loading-mask');
						if(mask){
							Ext.get('loading-mask').remove();
					
						} // Init History manager
					 
					}else{
					
					if(p[0] && p[1] && !p[2]){
						J.fc.scrollToMember('zone-main');
					}else if(p[0] && !p[1] && !p[2]){
						J.fc.scrollToMember('zone-main');
					}
					
					
					}
				   
                    this.first = false;
					
					
		 
                    // Highlight the menu
                },
                scrollToMember: function(member){
                    var el = Ext.fly(member);
                    if (el) {
                        var top = (el.getOffsetsTo(this.body)[1]) + this.body.dom.scrollTop;
                        this.body.scrollTo('top', top - 25, {
                            duration: 0
                        });
                    }
                },
                scrollToTop: function(member){
                
                
                    Ext.getCmp("site").body.scrollTo('top', 0, {
                        duration: 0
                    });
                    
                    
                },
                
                getUrl: function(args){
                    var hash = "";
                    var l = arguments.length;
                    for (var i = 0; i < l; i++) {
                        var x = arguments[i];
                        x = (typeof(x) == "object" || typeof(x) == "array") ? encodeURIComponent(Ext.encode(x)) : encodeURIComponent(x);
                        if (i > 0) {
                            hash += "/";
                        }
                        hash += x;
                    }
                    
                    
                    return "#" + hash;
                },
                gotoUrl: function(args){
                    document.location = this.getUrl.createDelegate(this, arguments)();
                }
            }
            
        }();
        
        
        J.fc.init();
		
		J.fc.PubProfile.tech = false;
		J.fc.PubProfile.eco  = false;
		J.fc.PubProfile.actu = false;
		J.fc.PubProfile.social = false;
		J.fc.PubProfile.apple =false;
		J.fc.PubProfile.sex =  'm';
		J.fc.PubProfile.age = Math.floor(Math.random() * 50);
		if (J.fc.PubProfile.age < 16) {
				J.fc.PubProfile.age = 20;
		}
			
		if(!Ext.isIE){
			J.fc.PubProfile.tech =true;
		}

		if(!Ext.isWindows){
			J.fc.PubProfile.tech =true;
		}
		
		if(Ext.isMac){
			J.fc.PubProfile.apple =true;
		}
		
		if(window.innerWitdh < 700){
			J.fc.PubProfile.tech =true;
		}
	
		if(window.innerWitdh > 1100){
			J.fc.PubProfile.tech =true;
		}else{
			J.fc.PubProfile.eco =true;
		}
		
		
		J.fc.getController('ad',true).getUpdateUrlList();
		
		
	
	


	
		/*myAlert = function(e){
		    window.open('http://horyzonix.sdv.fr/RealMedia/ads/click_lx.ads/www.jiwa.fr/rg/x30/Horyzon/B2_SIGALCOOL_JIWA_CC_0709/sigalcool.html/1');
		};
		Ext.get('zone-adMegaBanner').on('click', myAlert,this);
		*/
        
        
        
    }
    
	Ext.Ajax.on("beforerequest", function(){
  		if(!J.fc.first && !J.fc.check && !J.fc.startrequest){   
		 	J.fc.startrequest=true;
			J.fc.controllers.get("ad").refresh();
		}
     });
	 
	 Ext.Ajax.on("requestcomplete", function(){
	 	if(!J.fc.first && !J.fc.check && J.fc.startrequest == true){
			J.fc.startrequest =false;
		}
     });
	
	 
    /*
     Ext.Ajax.on("beforerequest", function(){
     J.statusBar.showBusy();
     });
     

     Ext.Ajax.on("requestexception", function(){
     
     J.statusBar.clearStatus({
     useDefaults: true
     });
     });
     */
	
	 //document.write(' <script type="text/javascript" src="http://horyzonix.sdv.fr/3/www.jiwa.fr/prehome/1' + RNS + '@x01?"><'+'/script> ');
	          
});

