/* Floor plan requires scriptaculous 1.8.3
 * Pete @ futuremedium.com.au wrote this.
 * */

if (typeof Effect == 'undefined') 
    throw ("floorplan requires including script.aculo.us' effects.js library!");


var floorplan = Class.create();
floorplan.prototype = {
  floorPlanID: 'floorPlanID',
  floorplanDiv: 'floorplan',
  hiddenField: 'floorPlanData',
  initialize: function() {
   this.createStoredLocations();

  },

  createLocation: function(x, y, src) {

    $(this.floorplanDiv).insert({
      top: elm = new Element('div', {className: 'location',
        style: 'position: absolute;left: ' + x + 'px;top: ' + y + 'px;'}).insert({
        top: new Element('a', {href: baseHref + 'floorplan?img=' + src + '&id=' + $(this.floorPlanID).value, rel: 'internal', className: 'lightwindow_action btn btn_location'}).insert({
          top: new Element('img', {src: imagesPath + 'btn_location.gif', width: '23', height: '48' })
        })
      })
    });
    
    return elm;
  },

  createStoredLocations: function() {
    if($(this.hiddenField) != null) {
      var locations = (decodeURI(($(this.hiddenField).value))).evalJSON(true);
      
      (locations.location).each(function(location) {
         this.createLocation(location.posX, location.posY, location.imgSrc);
      }.bind(this));
     
    }
  }
  
} 




 
