﻿/*
 *
 *	QuickBox (Another Lightbox clone)
 *
 *	Version: 1.0
 *	Documentation: AndrewPlummer.com (http://www.andrewplummer.com/code/quickbox/)
 *	Heavily inspired by: Slimbox by Christophe Beyls (http://www.digitalia.be)
 *	Written for: Mootools 1.2
 *	License: MIT-style License
 *	
 *	Copyright (c) 2008 Andrew Plummer
 *
 *
 */
function quickbox(link,width,height){
 this.close = function(){
  this.quickBox.setStyle("display", "none");
  this.overlay.fade("out");
  this.quickBox;
 };
 this.overlay = new Element("div", {
  id: "qbOverlay",
  events: {
   click: this.close.bindWithEvent(this)
  }
 });
 $$("#qbBox").each(function(el){el.dispose();});
 $$("#qbOverlay").each(function(el){el.dispose();});
 this.overlay.inject(document.body,"top");
 this.quickBox = new Element("div", {
  id: "qbBox",
  styles: {
   width: width,
   height: height,
   marginLeft: -(width/2),
   position: "absolute"
  }
 }).inject(document.body, "top");
 this.topbox = new Element("div", {id: "qbTop"}).inject(this.quickBox);
 this.closeButton= new Element("div", {
  id: "qbClose",
  events: {
   click: this.close.bindWithEvent(this)
  }
 }).inject(this.topbox);
 this.frame = new Element("iframe",{
  id:"qbFrame",
  src:link,
  frameborder:0,
  styles: {
   width:width-20,
   height:height-60,
   border:"none"
  }
 }).inject(this.quickBox);
 var size = window.getSize();
 var scroll = window.getScroll();
 var scrollSize = window.getScrollSize();
  
 var offset = Math.round((size.y < 768) ? size.y / 36 : size.y / 10);
  
 var top = scroll.y + offset;
 this.fx = {
  overlay: new Fx.Tween(this.overlay, {
   property: "opacity"
  })
 };
 this.overlay.setStyles({
  opacity: 0,
  display: "block",
  width: scrollSize.x,
  height: scrollSize.y
 });
 this.quickBox.setStyles({
  display: "block",
  top: top
 });
 this.fx.overlay.start(0.8);
};



