///////////////////////////////////////////////////////////////
//
//  Script: Contact Popup
//  Version: 1.0
//  Author: Craig Nelson / Classic Labs Development
//
//  Features: 
//    - auto calculates height and width.
//

  var Ascribe = Ascribe || {};
  
  Ascribe.Popup = function (config) {
    var that = this; // scope adjustment
    
    // elements
    this.popupContainer = config.popupContainer || $("contact");
    this.triggers = config.triggers || $$(".contact");
    
    // ids
    this.overlay = config.overlay || "ascribe-overlay";
    this.close = config.close || "contact-close";
    
    // get height for popup container
    this.dimensions = this.popupContainer.getDimensions();
    this.popupContainer.style.marginTop = "-" + (this.dimensions.height/2) + "px";
    this.popupContainer.style.marginLeft = "-" + (this.dimensions.width/2) + "px";
    
    // events
    this.triggers.each(function (e) {
      Event.observe(e, "click", function (event) {
        this.blur();
        event.preventDefault();
        Effect.Appear(that.overlay, { duration: .2, from: 0, to: .5 });
        Effect.Appear(that.popupContainer, { duration: .2, from: 0, to: 1 });
      });
    });
    
    Event.observe(this.close, "click", function (event) {
      this.blur();
      event.preventDefault();
      Effect.Fade(that.overlay, { duration: .2, from: .5, to: 0 });
      Effect.Fade(that.popupContainer, { duration: .2, from: 1, to: 0 });
    });
  } // constructor
