/* helper function to load multiple functions, courtesy Simon Wilson */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function popup(url,w,h,scroll)
{
  var l = (screen.width-w)/2;
  var t = (screen.height-h)/2;

  window.open(url,'_blank','resizable=yes,location=no,menubar=no,scrollbars='+scroll+',status=no,toolbar=no,fullscreen=no,dependent=no,width='+w+',height='+h+',left='+l+',top='+t);
}


function reloadValidationImage(key)
{
  if(document.getElementById('validationimage_'+key))
  {
    var now = new Date();
    newSrc = document.getElementById('validationimage_'+key).src
    newSrc = (newSrc.indexOf("?")>0)? newSrc.substr(0,newSrc.indexOf("?")) : newSrc;
    newSrc+= "?"+ now.getTime();
    document.getElementById('validationimage_'+key).src = newSrc;
  }
}




/*** ZIBB ***/
/************/


window.addEvent('domready', function()
{
/*  if (main_img = $('mainimg'))
  {
    //var main_img_div = $E('.car_ad_img');
    //var main_img = $('mainimg');
    var thumbnails = [];

    $$('.car_ad_thumb').each(function(el, i)
    {
      img_id = el.id.substr(3);
      thumbnails[i] = "http://www.leasetrader.nl/resources/uploads/images/auto/full/"+img_id+".jpg";

      el.addEvent('click', function(e) {
        main_img.set('src', imgs[i].get('src'));
        return false;
      });

    });

    var imgs = new Asset.images(thumbnails);
  }
*/
  if (make = $('selectmakeid'))
  {
    var req = new Request.HTML({
      "url":      site_base+"/resources/scripts/get_models.php"
     ,method:     'get'
     ,update:     $('makewrapper')
    });

    make.addEvent('change', function(e) {
      req.get({id: make.value});
    });
  }


});



function set_max(minlist, maxlist)
{
    if (maxlist.selectedIndex < minlist.selectedIndex)
    {
        maxlist.options[minlist.selectedIndex].selected = true;
    }

}

function set_min(minlist, maxlist)
{
    if (maxlist.selectedIndex < minlist.selectedIndex)
    {
        minlist.options[maxlist.options.selectedIndex].selected = true;
    }

}



// rewrite original replaceHeaders in ZIBB util.js to be sure..
function replaceHeaders()
{
  return true;
}
