var loader = { 
  imgs: [],
  load: function(src) {img=this.imgs; var ct=img.length; img[ct]=new Image();img[ct].src=src;}
};
$(function() {
	
  /* roll over */
  $("a.ro").each(function() { loader.load($(this).children('img').attr('src').replace(/(\.[a-z]{3})$/i,"_on$1"));});
  $("a.ro").mouseover(function() {
    var src=$(this).children('img').attr('src');
		if (src.match(/_on\./)) { return;}
    $(this).children('img').attr('src', src.replace(/(\.[a-z]{3})$/i,"_on$1"));
  });
  $("a.ro").mouseout(function() {
    if ($(this).hasClass('selected')) { return;}
    var src=$(this).children('img').attr('src');
    $(this).children('img').attr('src', src.replace(/_on/,""));
  });
  
  /* lightbox */
  sitetop = '/hotel_data/';
  $('a[rel*=lightbox]').lightBox({
		imageLoading: sitetop+'common/images/lightbox-ico-loading.gif',
		imageBtnClose: sitetop+'common/images/lightbox-btn-close.gif',
		imageBtnPrev: sitetop+'common/images/lightbox-btn-prev.gif',
		imageBtnNext: sitetop+'common/images/lightbox-btn-next.gif'
  });

})

function currency(n) {
    var result;
    var str = "" + n;
    var ary;
    if(!(ary = str.match(/^([\+-]|)(\d+)(\.\d+|)$/)))
        return "";
    var int_part = ary[2];
    var len = int_part.length;
    var mod = (len - 1) % 3 + 1;
    result = int_part.substr(0, mod);
    for(var i = mod; i < len; i += 3)
        result += "," + int_part.substr(i, 3);
    result = ary[1] + result + ary[3];
    return result;
}
