g_ref_models = "41,79,S320|41,68,E420|1,9,Legend|10,6,De Ville|11,29,Prizm|15,12,Sentra|19,6,328 GTS|21,33,Pickup|24,9,Odyssey|29,3,Vanden Plas|36,12,Zephyr|41,36,500SEC|42,9,Monterey|47,3,Achieva|50,18,Sunbird|51,9,Cayenne|54,3,9-2X|60,23,Supra|1,2,2.3CL|5,19,TT|8,59,850Ci|10,13,SRX|15,7,720|19,13,612 Scaglietti|24,2,Civic|29,8,XJ8|36,7,Mark 7|41,47,C240|42,2,Cougar|46,19,Titan|47,8,Ciera|54,8,9000|55,19,Vue|7,2,Azure|8,28,524td|9,7,Park Avenue|12,13,Intrepid|17,28,Ram Pickup|27,8,M30|30,2,CJ|34,7,Range Rover|41,8,280CE|53,2,Corniche|59,7,Sidekick|62,13,Pickup|9,12,Riviera|12,6,Conquest|17,23,Omni|21,6,Contour|27,3,G20|30,9,Wagoneer|41,3,190DT|45,18,Tredia|48,3,505|59,12,X-90|62,6,Fox|41,99,SLR|64,-1,Unspecified Yugo|5,17,S6|8,57,760Li|11,20,Impala|15,5,310|19,15,F131|21,40,Windstar|22,5,Tracker|29,10,XJS|36,5,Mark LT|41,45,C220|46,17,Sentra|55,17,SW2|1,11,NSX|3,-1,Unspecified AMC|4,1,DB7|10,4,Cimarron|11,31,S10 Pickup|21,35,Ranger|23,21,Vandura|24,11,Pilot|26,-1,Unspecified Hyundai|29,1,S-Type|40,-1,Unspecified Mazda|41,38,500SL|42,11,Mystique|47,1,88|49,-1,Unspecified Plymouth|50,16,Phoenix|54,1,3-sep|60,21,Solara|41,70,E500|41,77,ML500|41,97,SLK350|2,1,164|5,-1,Unspecified Audi|8,21,328Ci|9,14,Skyhawk|12,4,Cirrus|17,21,Monaco|27,1,FX35|28,-1,Unspecified Isuzu|41,1,190D 2.2|45,16,Sigma|46,-1,Unspecified Nissan|48,1,405|55,-1,Unspecified Saturn|62,4,Dasher|63,31,S60|3,17,Wrangler|9,5,LaCrosse|12,15,LHS|17,30,Ram Van|21,15,Explorer|27,10,M45|34,5,Land Rover|40,17,RX-8|41,10,300CD|49,17,Sundance|59,5,Reno|62,15,R32|3,1,Alliance|4,-1,Unspecified Aston Martin Models|11,35,Spectrum|17,14,Durango|20,4,Pininfarina|21,31,LTD|26,1,Accent|29,-1,Unspecified Jaguar|35,14,RX300|38,4,Coupe|40,1,323|41,26,380SE|47,-1,Unspecified Oldsmobile|49,1,Acclaim|54,-1,Unspecified Saab|3,10,Grand Wagoneer|8,5,320i|11,40,Tracker|12,20,Prowler|17,5,Caravan|21,20,F350|35,5,GS400|40,10,MPV|49,10,Horizon|58,5,Forester|62,20,Vanagon|63,15,765 GLE|8,73,Z3|41,93,SLK230|8,66,M SERIES|41,86,S600|5,10,A8|11,15,Corvette|17,34,Shadow|19,20,F575|28,10,Stylus|41,54,CL500|46,10,NX|47,17,Toronado|55,10,Relay|60,5,Corolla|63,40,XC70 and V70 Cross Country|1,16,Vigor|2,-1,Unspecified Alfa Romeo|5,1,100|11,4,Beretta|18,4,Talon|27,-1,Unspecified Infiniti|28,1,Amigo|32,4,Jalpa|41,-1,Unspecified Mercedes-Benz|41,61,CLK55 AMG|42,16,Villager|46,1,200SX|48,-1,Unspecified Peugeot Models|50,11,GTO|55,1,ION|60,14,Paseo|3,8,Eagle|6,2,Coupe|8,7,323i|12,22,Sebring|17,7,Charger|21,22,Festiva|26,8,Tiburon|31,2,Optima|35,7,GX470|40,8,Miata MX5|45,2,Cordia|49,8,Gran Fury|52,2,18I|58,7,Impreza|63,13,760|11,33,Silverado and other CK2500|17,12,Daytona|21,29,GT|26,3,Excel|35,12,LX470|38,6,Quattroporte|40,3,929|41,24,350SD|45,9,Mirage|49,3,Breeze|58,12,RX|63,6,244 GL|5,3,4000|8,43,633CSi|11,6,Camaro|18,6,Vision|23,12,Sierra|28,3,Axiom|32,6,Murcielago|41,63,CLS55 AMG|46,3,280ZX|50,9,Grand Am|55,3,L200|60,12,MR2|63,33,S80|5,8,A4|8,32,528e|11,13,Colorado|17,32,Ramcharger|19,22,Testarossa|23,7,Pickup|25,2,H2|28,8,Pickup|41,52,C43|46,8,Maxima|50,2,Aztek|60,7,Cressida|8,64,M Coupe|41,84,S500|64,1,GV|8,75,Z8|41,95,SLK32 AMG|3,4,CJ5|8,11,325|9,16,Somerset|10,-1,Unspecified Cadillac|11,38,Suburban|12,26,Voyager|13,1,Lanos|17,11,Dakota|19,-1,Unspecified Ferrari Models|20,1,124|21,26,Freestyle|26,4,Pony|33,-1,Unspecified Lancia Models|35,11,LX450|38,1,425|40,4,B-Series Pickup|41,31,400E|45,14,Precis|49,4,Caravelle|58,11,Outback|63,1,240|11,45,Venture|12,17,New Yorker|21,17,F Super Duty|31,5,Sephia|41,20,300SL|45,5,Endeavor|49,15,Sapporo|52,5,R18|62,17,Scirocco|5,15,RS 6|8,39,535i|11,10,Chevette|17,39,Stealth|19,17,F40|41,51,C36 AMG|46,15,Quest|50,5,Fiero|5,4,5000|8,44,635CSi|11,1,Astro|12,-1,Unspecified Chrysler|18,1,Medallion|21,-1,Unspecified Ford|23,11,Savana|28,4,Hombre|32,1,Countach|39,-1,Unspecified Maybach Models|41,56,CL600|46,4,300ZX|50,14,Montana|55,4,L300|57,1,825|60,11,Matrix|62,-1,Unspecified Volkswagen|63,38,V70|41,88,SL320|8,71,X3|41,83,S430|3,13,Scrambler|12,19,Pacifica|17,2,600|21,19,F250|31,7,Spectra|35,2,ES300|40,13,Navajo|45,7,Galant|49,13,Prowler|52,7,Sportwagon|58,2,Baja|3,6,Comanche|11,36,Sprint|12,24,Town &amp; Country|13,3,Nubira|17,9,Conquest|20,3,Brava|21,24,Focus|26,6,Scoupe|35,9,LS400|38,3,Biturbo|40,6,Mazda3|41,29,380SL|45,12,Outlander|49,6,Colt|58,9,Legacy|8,69,M6|41,90,SL55 AMG|5,6,90|8,46,733i|11,3,Aveo|18,3,Summit|23,9,S15 Pickup|28,6,Impulse|32,3,Gallardo|41,58,CLK320|46,6,Altima|50,12,J2000|55,6,LW1|60,9,Highlander|63,36,V40|5,13,Coupe|8,37,530xi|11,8,Cavalier|14,2,Rocky|17,37,SRT-4|19,19,F550|23,2,Canyon|37,2,Elise|41,49,C32 AMG|46,13,PICKUP|55,13,SL|60,2,Avalon|1,12,RSX|8,53,750i|10,3,Catera|11,24,Malibu|15,9,Maxima|19,3,308 GTS|21,36,Taurus|23,18,Syclone|24,12,Prelude|29,6,XJ12|33,3,Zagato|36,9,Navigator|42,12,Sable|47,6,Bravada|54,6,9-7x|56,3,xB|60,18,RAV4|1,7,3.5RL|8,62,L6|10,8,Escalade|11,19,G Van|15,2,210|19,8,348 GTS|22,2,Prizm|24,7,EV Plus|29,13,XKR|36,2,Blackwood|41,42,600SEC|42,7,Marquis|46,22,Xterra|47,13,Ninety-Eight|51,7,Boxster|60,25,Tacoma|61,2,TR-8|41,74,ML320|41,65,E320|7,7,Mulsanne|8,25,330Ci|9,2,Electra|12,8,Crossfire|17,25,Ram 1500 Truck|21,8,Crown Victoria|27,13,QX56|30,7,Pickup|34,2,Discovery|41,13,300D|53,7,Silver Spirit|59,2,Esteem|62,8,GTI|9,9,Reatta|12,3,Caravan|17,18,Lancer|21,3,Bronco|27,6,I35|35,18,SC430|41,6,240D|62,3,Corrado|41,67,E350|41,72,G500|1,5,3.2CL|8,60,850CSi|11,17,Equinox|19,10,360|24,5,Del Sol|41,40,560SEL|42,5,Marauder|47,15,Regency|51,5,944|60,27,Tundra|1,14,TSX|4,4,Vanquish|8,55,750Li|10,1,Allante|11,26,Monte Carlo|13,-1,Unspecified Daewoo|15,11,Pulsar|19,1,308 GTB|20,-1,Unspecified Fiat Models|21,38,Thunderbird|23,16,Sonoma|24,14,S2000|29,4,X-Type|33,1,Beta|38,-1,Unspecified Maserati Models|41,35,500E|42,14,Tracer|47,4,Alero|50,21,Trans Am|54,4,9-3|56,1,tC|60,16,Previa|63,-1,Unspecified Volvo|2,4,Milano|9,11,Rendezvous|11,-1,Unspecified Chevrolet|12,1,300|17,16,Grand Caravan|18,-1,Unspecified Eagle|21,1,Aerostar|27,4,G35|32,-1,Unspecified Lamborghini Models|35,16,SC300|39,1,57|41,4,190E 2.3|48,4,604|57,-1,Unspecified Sterling Models|59,11,Vitara|62,1,Cabrio|63,26,C70|7,5,Continental|8,27,330xi|12,10,Executive|17,27,Ram 3500 Truck|21,10,Escape|30,5,Grand Wagoneer|41,15,300E|49,20,Voyager|53,5,Silver Dawn|62,10,New Beetle|63,17,850|5,5,80|8,45,645Ci|23,10,Safari|28,5,I-Mark|41,57,CL65 AMG|46,5,350Z|50,15,Parisienne|55,5,LS|60,10,Land Cruiser|63,39,V90|5,14,Quattro|8,38,533i|9,-1,Unspecified Buick|10,16,XLR|11,11,Citation|14,1,Charade|17,38,St. Regis|19,16,F355|23,1,Caballero|28,14,VehiCROSS|34,-1,Unspecified Land Rover|37,1,Elan|41,50,C320|46,14,Pulsar|50,4,Catalina|59,-1,Unspecified Suzuki|60,1,4Runner|41,82,S420|41,89,SL500|3,14,Spirit|8,1,318i|11,44,Uplander|12,16,Neon|15,-1,Unspecified Datsun|17,1,400|22,-1,Unspecified Geo|31,4,Sedona|35,1,ES250|36,-1,Unspecified Lincoln|40,14,Protege|41,21,300TD|45,4,Eclipse|49,14,Reliant|52,4,Le Car|58,1,B9 Tribeca|61,-1,Unspecified Triumph|62,16,Rabbit|3,5,CJ7|9,17,Terraza|11,39,Tahoe|17,10,D50 Pick Up|21,27,Fusion|26,5,Santa Fe|35,10,LS430|40,5,GLC|45,15,Sapporo|49,5,Champ|58,10,Loyale|41,91,SL600|8,68,M5|41,80,S350|5,12,Cabriolet|11,9,Celebrity|17,36,Sprinter|19,18,F430|23,3,Envoy|37,3,Esprit|41,48,C280|50,6,Firebird|55,12,SC2|60,3,Camry|5,7,A3|8,47,735i|11,2,Avalanche|18,2,Premier|23,8,Rally Wagon|28,7,Oasis|32,2,Diablo|41,59,CLK430|46,7,Frontier|50,13,Le Mans|55,7,LW2|57,2,827|60,8,Echo|63,37,V50|3,7,Concord|11,37,SSR|13,2,Leganza|17,8,Colt|20,2,Bertone|21,25,Freestar|26,7,Sonata|35,8,IS300|38,2,430|40,7,Mazda6|45,13,Pickup|49,7,Conquest|58,8,Justy|3,12,J20|12,18,Newport|17,3,Aries|21,18,F150|26,12,XG350|31,6,Sorento|35,3,ES330|40,12,MX6|41,23,300TE|45,6,Expo|49,12,Neon|52,6,R5|58,3,Brat|62,18,Touareg|63,9,740|9,8,Rainier|17,19,Magnum|21,2,Aspire|27,7,J30|39,2,62|41,7,260E|59,8,Swift|63,25,960|7,6,Corniche|9,3,Estate Wagon|12,9,E Class|17,24,Raider|21,9,Econoline|27,12,QX4|30,6,Liberty|41,12,300CE|53,6,Silver Seraph|59,3,Forenza|62,9,Jetta|1,6,3.2TL|8,63,L7|11,18,Express Van|15,3,280 ZX|19,9,348 Spider|22,3,Spectrum|24,6,Element|29,12,XKE Series|36,3,Continental|41,43,600SEL|42,6,Mariner|47,12,Intrigue|51,6,968|60,24,T100|1,13,SLX|8,52,745Li|10,2,Brougham|11,25,Metro|15,8,810|21,37,Tempo|23,19,Typhoon|24,13,Ridgeline|29,7,XJ6|36,8,Mark 8|41,32,400SE|42,13,Topaz|47,7,Calais|50,22,Trans Sport|56,2,xA|60,19,Sequoia|41,64,E300|41,75,ML350|7,4,Brooklands|8,26,330i|9,1,Century|12,11,Fifth Avenue|14,-1,Unspecified Daihatsu|16,1,DMC-12|17,26,Ram 2500 Truck|21,11,Escort|23,-1,Unspecified GMC|30,4,Grand Cherokee|34,1,Defender|37,-1,Unspecified Lotus Models|53,4,Phantom|59,1,Aerio|60,-1,Unspecified Toyota|62,11,Passat|63,16,780|2,5,Spider|9,10,Regal|17,17,Intrepid|27,5,I30|35,17,SC400|41,5,190E 2.6|59,10,Verona|63,27,DL|41,73,G55 AMG|4,5,Virage|11,27,Nova|15,10,Pickup|23,17,Suburban|29,5,XJ Series|36,10,Town Car|41,34,420SEL|47,5,Aurora|50,20,T-1000|54,5,9-5|60,17,Prius|1,4,3.0CL|5,21,V8 Quattro|8,-1,Unspecified BMW|8,61,850i|10,11,Fleetwood|11,16,El Camino|15,1,200SX|17,-1,Unspecified Dodge|19,11,456 GT|22,1,Metro|24,4,CRX|35,-1,Unspecified Lexus|36,1,Aviator|41,41,560SL|42,4,Lynx|46,21,Van|47,14,Omega|51,4,928|58,-1,Unspecified Subaru|60,26,Tercel|61,1,TR-7|2,2,GTV|8,22,328i|9,13,Roadmaster|12,7,Cordoba|17,22,Neon|21,7,Courier|27,2,FX45|41,2,190D 2.5|48,2,504|53,8,Silver Spur|59,13,XL-7|62,7,Golf|63,28,GL|7,3,Bentley|8,29,525i|9,6,Le Sabre|12,12,Imperial|17,29,Ram SRT-10|21,12,Excursion|27,9,M35|30,3,Comanche|34,6,LR3|40,18,Tribute|41,9,280E|49,18,Trailduster|53,3,Park Ward|59,6,Samurai|62,12,Phaeton|41,98,SLK55 AMG|41,69,E430|41,78,ML55 AMG|1,3,2.5TL|5,18,S8|8,58,840Ci|10,12,Seville|11,23,LUV|15,6,510|19,12,512TR|24,3,CR-V|29,9,XJR|36,6,Mark 6|41,46,C230|42,3,Grand Marquis|46,18,Stanza|47,9,Cutlass|50,24,Vibe|51,3,924|60,29,Van|1,8,Integra|4,2,DB9|8,49,740i|10,7,Eldorado|11,28,Pickup|15,13,Stanza|19,7,348 GTB|21,32,Mustang|23,22,Yukon|24,8,Insight|41,37,500SEL|42,8,Montego|50,19,Sunfire|51,8,Carrera GT|54,2,5-sep|60,22,Starlet|41,96,SLK320|3,16,Wagoneer|7,1,Arnage|8,31,525xi|9,4,Grand National|12,14,LeBaron|17,31,Ram Wagon|21,14,Expedition|25,-1,Unspecified Hummer|27,11,Q45|30,1,Cherokee|34,4,Freelander|40,16,RX-7|43,-1,Unspecified Merkur|44,1,Cooper|49,16,Scamp|50,-1,Unspecified Pontiac|53,1,Camargue|59,4,Grand Vitara|62,14,Quantum|63,21,940|9,15,Skylark|12,5,Concorde|17,20,Mirada|21,5,Club Wagon|30,10,Wrangler|45,17,Starion|62,5,Eurovan|63,30,S40|1,10,MDX|8,51,745i|10,5,CTS|11,30,S10 Blazer|19,5,328 GTB|21,34,Probe|24,10,Passport|41,39,560SEC|42,10,Mountaineer|50,17,Safari|60,20,Sienna|1,1,2.2CL|5,16,S4|6,-1,Unspecified Avanti Models|8,56,760i|10,14,STS|11,21,Lumina|15,4,300 ZX|19,14,Enzo|21,41,ZX2 Escort|22,4,Storm|24,1,Accord|29,11,XK8|31,-1,Unspecified Kia|36,4,LS|41,44,600SL|42,1,Capri|45,-1,Unspecified Mitsubishi|46,16,SE-R|47,11,Firenza|51,1,911|52,-1,Unspecified Renault Models|55,16,SW1|41,76,ML430|41,71,E55 AMG|8,67,M3|41,87,S65 AMG|8,72,X5|41,92,SL65 AMG|8,40,540i|11,5,Blazer|17,40,Stratus|32,5,LM|41,60,CLK500|42,17,Zephyr|50,10,Grand Prix|60,15,Pickup|63,34,S90|5,11,Allroad Quattro|7,-1,Unspecified Bentley Models|8,35,530i|11,14,Corsica|17,35,Spirit|19,21,Mondial|25,1,H1|28,11,Trooper|30,-1,Unspecified Jeep|41,55,CL55 AMG|43,1,Scorpio|46,11,Pathfinder|47,16,Silhouette|50,1,6000|53,-1,Unspecified Rolls-Royce Models|55,11,SC1|60,4,Celica|63,41,XC90|1,-1,Unspecified Acura|3,11,J10|6,1,Convertible|11,41,TrailBlazer|12,21,PT Cruiser|17,4,Avenger|21,21,Fairmont|24,-1,Unspecified Honda|26,11,XG300|31,1,Amanti|35,4,GS300|40,11,MX3|41,16,300SD|42,-1,Unspecified Mercury|45,1,3000GT|49,11,Laser|51,-1,Unspecified Porsche|52,1,181|58,4,DL|11,34,Silverado and other CK3500|17,15,Dynasty|20,5,Strada|21,30,Laser|35,15,RX330|38,5,GranSport|45,10,Montero|58,15,XT|5,9,A6|8,33,528i|11,12,Cobalt|17,33,Rampage|23,6,Jimmy|25,3,H3|28,9,Rodeo|41,53,C55 AMG|43,3,XR4TI|46,9,Murano|50,3,Bonneville|55,9,LW300|60,6,Corona|5,2,200|8,42,545i|11,7,Caprice|17,42,Viper|28,2,Ascender|41,62,CLS500|46,2,240SX|50,8,G6|55,2,L100|63,32,S70|8,74,Z4|41,94,SLK280|8,65,M Roadster|41,85,S55 AMG|3,2,Cherokee|11,32,Silverado and other CK1500|17,13,Diplomat|20,7,X19|21,28,Granada|26,2,Elantra|31,8,Sportage|35,13,RX 400h|38,7,Spyder|40,2,626|45,8,Lancer|49,2,Arrow|58,13,SVX|63,7,260|3,9,Encore|6,3,Sedan|8,6,323ci|12,23,Town & Country|17,6,Challenger|21,23,Five Hundred|26,9,Tucson|31,3,Rio|35,6,GS430|40,9,Millenia|41,18,300SE|45,3,Diamante|49,9,Grand Voyager|52,3,Fuego|58,6,GL|"; 



/* --- load arrays --- */
function load_arrays()
{
   g_arr_models  = g_ref_models.split('|');
}

function add_options(l_option,l_array)
{
   i=0;
   while (l_array[i])
   {
      l_arr_model = l_array[i].split(',');
      l_model = l_arr_model[0];
      l_model_txt = l_arr_model[1];

     // --- check for duplicates ---
      l_equal = 0;
      l_len = l_option.options.length;
      for(j=0;j<l_len;j++)
      {
         if (l_model == l_option.options[j].value)
         {
            l_equal = 1;
            break;
         }
      }
      if (l_equal)
      {
         i++;
         continue;
      }

     // --- add new option ---
      l_new_option = new Option(l_model_txt, l_model, false, false);
      l_option.options[l_len] = l_new_option;

      i++;
   }
}


/* --- remove all options from select list --- */
function clean_options(l_option)
{
   l_option.selectedIndex = 0;
   l_len = l_option.options.length;
   for (i=l_len-1;i>0;i--)
      l_option.options[i] = null;
}


function populate_models(l_make)
{
   l_option = l_make.options[l_make.options.selectedIndex].value;

  // --- build appropriate array ---
   l_arr_models = new Array();

   i=0;
   idx=0;
   var l_mmake,l_model,l_model_txt;
   while (g_arr_models[i])
   {
      l_arr_model = g_arr_models[i].split(',');
      l_make      = l_arr_model[0];
      l_model     = l_arr_model[1];
      l_model_txt = l_arr_model[2];

      if (l_make == l_option)
      {
         l_arr_models[idx++] = l_model + "," + l_model_txt;
      }
      i++;
   }

  // --- add array as makes ---
   clean_options(document.forms["adentry"].elements["model"]);
   add_options(document.forms["adentry"].elements["model"],l_arr_models);

}
load_arrays();



// --- set checkboxes according to key ---
function set_checked(l_check_key)
{

   l_cnt = eval(document.forms["adentry"].elements["feature_cnt"].value);

   for(i=1;i<=l_cnt;i++)
   {
      l_fldname = 'f' + i;
      l_checked = eval(l_check_key.charAt(i-1));
      if (l_checked) 
         document.forms["adentry"].elements[l_fldname].checked = true;
      else
         document.forms["adentry"].elements[l_fldname].checked = false;
   }
 
}

function MakeFeatureKey()
{
   l_cnt = eval(document.forms["adentry"].elements["feature_cnt"].value);

  // --- locate features ---
   l_len = eval(document.forms["adentry"].elements.length);
   for(j=0;j<=l_len;j++)
   {
      if ((document.forms["adentry"].elements[j].name.indexOf("f")==0) &&
          (document.forms["adentry"].elements[j].name.length<=3))
         break;
   }
  
  // --- build key ---
   l_key = new String();
   for(i=0;i<l_cnt;i++)
   {
      l_key += "0";
   }
   for(i=0;i<l_cnt;i++)
   {
      l_checked = document.forms["adentry"].elements[i+j].checked;
      l_fldname = new String(document.forms["adentry"].elements[i+j].name);
      l_fldno   = new Number(l_fldname.slice(1));
  
  
      if (l_checked)
      {
         l_key = l_key.substr(0,l_fldno-1) + "1" + l_key.substr(l_fldno);
      }
   }
  
  // --- force re-display of key (for errors) ---
   set_checked(l_key);
  
  // --- send this key to server ---
   document.forms["adentry"].elements["features"].value = l_key;

}

function ChkDesc()
{
   l_len = parseInt(document.forms["adentry"].elements["descrip_content"].value.length);
   document.forms["adentry"].elements["descrip_len"].value=l_len;

   if (l_len > 1300)
   {
      alert("Max description is 1300 characters.  Your description is currently " + l_len + " characters...");
      return false;
   }
   return true;
}


// --- check that e-mail address was entered ---
function ChkEmail(l_email)
{
   l_val = new String(l_email.value);
   if (l_val.length == 0)
      return;

   if (l_val.length == 0 || l_val.indexOf("@") == -1 || l_val.indexOf(".") == -1)
   {
      alert("Invalid e-mail address, please re-enter!");
      l_email.focus();
   }
}

// --- check if a field is empty ---
function ChkEmpty(l_item,l_name)
{
   l_val = new String(l_item.value);
   if (l_val.length == 0)
   {
      alert('"' + l_name + '"' + " canont be empty!");
      l_item.focus();
      return true;
   }
   return false;
}

function ChkNumeric(l_item,l_name)
{
   if(isNaN(l_item.value))
   {
      alert("\"" + l_item.value + "\" is not a valid " + l_name + "!");
      l_item.focus();
      return false;
   }
   return true;
}


// --- check all fields ---
function ChkAll()
{
   MakeFeatureKey();

   /* --- password --- */
   l_fld = document.forms["adentry"].elements["password1"];
   if ((l_fld.value == "") ||
       (l_fld.value != document.forms["adentry"].elements["password2"].value))
   {
      alert("Passwords cannot be empty, and must be the same!");
      l_fld.focus();
      return false;
   }

   /* --- make --- */
   l_fld = document.forms["adentry"].elements["make"];
   if (l_fld.value == 0)
   {
      alert("Please select a make!");
      l_fld.focus();
      return false;
   }

   /* --- model --- */
   l_fld = document.forms["adentry"].elements["model"];
   if (l_fld.value == 0)
   {
      alert("Please select a model!");
      l_fld.focus();
      return false;
   }
       
  /* --- year --- */
   if(ChkEmpty(document.forms["adentry"].elements["year"],"Year")) 
      return false;

  /* --- price --- */
   if(ChkEmpty(document.forms["adentry"].elements["price"],"Price")) 
      return false;

  /* --- mileage --- */
   if(ChkEmpty(document.forms["adentry"].elements["mileage"],"Mileage")) 
      return false;

  /* --- description --- */
   if(ChkEmpty(document.forms["adentry"].elements["descrip"],"Description")) 
      return false;

   if(!ChkDesc()) 
      return false;

  

  /* --- email/tel1/tel2 --- */
   l_tel1  = new String(document.forms["adentry"].elements["ctact_tel1"].value);
   l_tel2  = new String(document.forms["adentry"].elements["ctact_tel1"].value);
   l_email = new String(document.forms["adentry"].elements["ctact_email"].value);
   if (l_tel1.length == 0 && l_tel2.length  == 0 && l_email.length == 0)
   {
      alert("No contact details supplied!  Please enter either telephone or e-mail!");
      return false;
   }

  /* --- zipcode --- */
   if(ChkEmpty(document.forms["adentry"].elements["zipcode"],"Zipcode")) 
      return false;

   return true;
}

function init_features()
{
   set_checked(document.forms["adentry"].elements["features"].value);
   ChkDesc();
   set_menu_active('free');
}
