function _el(id){
    return document.getElementById(id);
}

function openWindow() { //v1.0
  var args = openWindow.arguments;
  var theURL = args[0];
  var winName = (args[1]) ? args[1] : 'popup';
  var width = (args[2]) ? args[2] : 500;
  var height = (args[3]) ? args[3] :  200;
  var features = (args[4]) ? "" : "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,";
  features = features + "width=" + width + ",height=" + height;
  var w = window.open(theURL,winName,features);
  w.focus();
  return w;
}

function bl(id) { // blank out links :D
  if (_el(id)) {
    if (_el(id).href) _el(id).href='#';
  } 
}

/* Property Pages */
function changeMainImage(id,src,title) {
    if (oldThumbID!=-1) {
        _el('th'+oldThumbID).className = '';
    }
    oldThumbID = id;
    //_el('imageDesc').innerHTML = title;
    _el('th'+id).className = 'thumbSelected';
    _el('mainImage').title=title;
    _el('mainImage').src=src;

}

/* search page and home page */
var brittany = new Array("(Any in Brittany)","","22 Cotes-d'Armor","cotesdarmor","29 Finistere","finistere","35 Ille-et-Vilaine","illeetvilaine","56 Morbihan","morbihan");
var dordogne = new Array("(Any)","","24 Dordogne","dordogne");
var east = new Array("(Any in the East)","","01 Ain","ain","03 Allier","allier","15 Cantal","cantal","21 Cote-d'Or","cotedor","25 Doubs","doubs","38 Isere","isere","39 Jura","jura","42 Loire","loire","43 Haute-Loire","hauteloire","58 Nievre","nievre","63 Puy-de-Dome","puydedome","69 Rhone","rhone","70 Haute-Saone","hautesaone","71 Saone-et-Loire","saoneetloire","73 Savoie","savoie","74 Haute-Savoie","hautesavoie","89 Yonne","yonne");
var loire = new Array("(Any in the Loire)","","18 Cher","cher","36 Indre","indre","37 Indre-et-Loire","indreetloire","41 Loire-et-Cher","loireetcher","44 Loire-Atlantique","loireatlantique","49 Maine-et-Loire","maineetloire","53 Mayenne","mayenne","72 Sarthe","sarthe");
var normandy = new Array("(Any in Normandy)","","14 Calvados","calvados","27 Eure","eure","28 Eure-et-Loir","eureetloir","50 Manche","manche","61 Orne","orne","76 Seine-Maritime","seinemaritime");
var northeast = new Array("(Any in the North East)","","02 Aisne","aisne","08 Ardennes","ardennes","10 Aube","aube","45 Loiret","loiret","51 Marne","marne","52 Haute-Marne","hautemarne","54 Meurthe-et-Moselle","meurtheetmoselle","55 Meuse","meuse","57 Moselle","moselle","59 Nord","nord","60 Oise","oise","62 Pas-de-Calais","pasdecalais","67 Bas-Rhin","basrhin","68 Haut-Rhin","hautrhin","75 Paris","iledefrance","77 Seine-et-Marne","iledefrance","78 Yvelines","iledefrance","80 Somme","somme","88 Vosges","vosges","90 Territoire de Belfort","territoiredebelfort","91 Essone","iledefrance","92 Hauts-de-Seine","iledefrance","93 Seine-Saint-Denis","iledefrance","94 Val-de-Marne","iledefrance","95 Val-d'Oise","iledefrance");
var southeast = new Array("(Any in the South East)","","02A Corse-du-Sud","corsesud","02B Haute-Corse","hautecorse","04 Alpes-de-Haute-Provences","alpesdehauteprovence","05 Hautes-Alpes","hautesalpes","06 Alpes-Maritime","alpesmaritime","07 Ardeche","ardeche","13 Bouches-du-Rhone","bouchesdurhone","20 Corse","corse","26 Drome","drome","30 Gard","gard","34 Herault","herault","48 Lozere","lozere","83 Var","var","84 Vaucluse","vaucluse");
var southwest = new Array("(Any in the South West)","","09 Ariege","ariege","11 Aude","aude","12 Aveyron","aveyron","31 Haute-Garonne","hautegaronne","32 Gers","gers","33 Gironde","gironde","40 Landes","landes","46 Lot","lot","47 Lot-et-Garonne","lotetgaronne","64 Pyrenees-Atlantiques","pyreneesatlantiques","65 Hautes-Pyrenees","hautespyrenees","66 Pyrenees-Orientales","pyreneesorientales","81 Tarn","tarn","82 Tarn-et-Garonne","tarnetgaronne");
var west = new Array("(Any in the West)","","16 Charente","charente","17 Charente-Maritime","charentemaritime","19 Correze","correze","23 Creuse","creuse","79 Deux-Sevres","deuxsevres","85 Vendee","vendee","86 Vienne","vienne","87 Haute-Vienne","hautevienne");
var franceregionssml = new Array("(Any)","","01 Ain","ain","02 Aisne","aisne","02A Corse-du-Sud","corsesud","02B Haute-Corse","hautecorse","03 Allier","allier","04 Alpes-de-Haute-Provences","alpesdehauteprovence","05 Hautes-Alpes","hautesalpes","06 Alpes-Maritime","alpesmaritime","07 Ardeche","ardeche","08 Ardennes","ardennes","09 Ariege","ariege","10 Aube","aube","11 Aude","aude","12 Aveyron","aveyron","13 Bouches-du-Rhone","bouchesdurhone","14 Calvados","calvados","15 Cantal","cantal","16 Charente","charente","17 Charente-Maritime","charentemaritime","18 Cher","cher","19 Correze","correze","20 Corse","corse","21 Cote-d'Or","cotedor","22 Cotes-d'Armor","cotesdarmor","23 Creuse","creuse","24 Dordogne","dordogne","25 Doubs","doubs","26 Drome","drome","27 Eure","eure","28 Eure-et-Loir","eureetloir","29 Finistere","finistere","30 Gard","gard","31 Haute-Garonne","hautegaronne","32 Gers","gers","33 Gironde","gironde","34 Herault","herault","35 Ille-et-Vilaine","illeetvilaine","36 Indre","indre","37 Indre-et-Loire","indreetloire","38 Isere","isere","39 Jura","jura","40 Landes","landes","41 Loire-et-Cher","loireetcher","42 Loire","loire","43 Haute-Loire","hauteloire","44 Loire-Atlantique","loireatlantique","45 Loiret","loiret","46 Lot","lot","47 Lot-et-Garonne","lotetgaronne","48 Lozere","lozere","49 Maine-et-Loire","maineetloire","50 Manche","manche","51 Marne","marne","52 Haute-Marne","hautemarne","53 Mayenne","mayenne","54 Meurthe-et-Moselle","meurtheetmoselle","55 Meuse","meuse","56 Morbihan","morbihan","57 Moselle","moselle","58 Nievre","nievre","59 Nord","nord","60 Oise","oise","61 Orne","orne","62 Pas-de-Calais","pasdecalais","63 Puy-de-Dome","puydedome","64 Pyrenees-Atlantiques","pyreneesatlantiques","65 Hautes-Pyrenees","hautespyrenees","66 Pyrenees-Orientales","pyreneesorientales","67 Bas-Rhin","basrhin","68 Haut-Rhin","hautrhin","69 Rhone","rhone","70 Haute-Saone","hautesaone","71 Saone-et-Loire","saoneetloire","72 Sarthe","sarthe","73 Savoie","savoie","74 Haute-Savoie","hautesavoie","75 Paris","iledefrance","76 Seine-Maritime","seinemaritime","77 Seine-et-Marne","iledefrance","78 Yvelines","iledefrance","79 Deux-Sevres","deuxsevres","80 Somme","somme","81 Tarn","tarn","82 Tarn-et-Garonne","tarnetgaronne","83 Var","var","84 Vaucluse","vaucluse","85 Vendee","vendee","86 Vienne","vienne","87 Haute-Vienne","hautevienne","88 Vosges","vosges","89 Yonne","yonne","90 Territoire de Belfort","territoiredebelfort","91 Essone","iledefrance","92 Hauts-de-Seine","iledefrance","93 Seine-Saint-Denis","iledefrance","94 Val-de-Marne","iledefrance","95 Val-d'Oise","iledefrance");


function changeRegion(region) {
  if (region=='') {
    region = 'franceregionssml';
  }
  _el('department').value='';
  var theDepts = eval(region);
  if (region == 'franceregionssml') region = '';
  var dptm = _el('department');
  if (dptm) {
    if (dptm.options) {
      for (i = dptm.options.length; i >= 0; i--) {
        dptm.options[i] = null;
      }
    }
    var optNo = 0;
    for (loop=0; loop < theDepts.length - 1; loop+=2) {
       dptm.options[optNo] = new Option(theDepts[loop],theDepts[loop+1]);
          optNo++;
    }
  }
  _el('region').value=region;
}

function changeDepartment(d) {
  if (d != '') {
    m='departments/'+d;
  } else {
    m=_el('region').value;
  }
  _el('imgMap').src='/img/map/'+m+'.gif';
  _el('department').value=d;
  ads_do_qsearch();
}

function do_pool(p) {
  if (p) _el('haspool').checked="checked";
}

function check_pool(p) {
  if (!p) _el('privatepool').checked='';
}

var sdate=false;
var edate=false;

/* Calendar Functions */
function startDate(cal) {
  sdate=cal.date;
  ads_do_qsearch();
}

function endDate(cal) {
  edate=cal.date;
  ads_do_qsearch();
}

function validateStartDate (date, y, m, d) {
  if (edate) {
    return (date>edate);
  } else {
    return false;
  }
}

function validateEndDate (date, y, m, d) {
  if (sdate) {
    return (date<sdate);
  } else {
    return false;
  }
}

function clearDates() {
  sdate=false; edate=false;
  _el('start_date').value='';
  _el('end_date').value='';
  _el('dstart_date').innerHTML='&raquo; Click here &laquo;';
  _el('dend_date').innerHTML='&raquo; Click here &laquo;';
  ads_do_qsearch();
}

types=new Object;

function clearme(fld,type) {
  if (!types[type]) {
    fld.value='';
    types[type]=1;
  }
}


function showHide(id, show) {
  var s='';
  if (show) {
    if (!document.all) s='block';
  } else {
    s='none';
  }
  _el(id).style.display=s;
}


function do_more_details(show) {
  showHide('moredetails',show);
  var w=(show)?'less':'more';
  _el('moreless').innerHTML='<a href="#" onClick="do_more_details('+!show+')">'+w+' &raquo;</a>';
}
