function clickButton(e, id){
  
  var keynum;
  var keychar;
  var numcheck;

  if(window.event) // IE
  {
    keynum = e.keyCode;
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which;
  }
  if(keynum == 13)
    document.getElementById(id).click();
  return false;

}


function showPopup(url){
  
  document.getElementById('overlay').innerHTML = '<div id="popupHeader"><a href="javascript:closePopup();" id="closeBtn"></a></div><div id="popupBody"><iframe src ="'+url+'" width="512" height="1" frameBorder="0" id="popupContent"></iframe></div><div id="popupFooter"></div>';
  
}

function closePopup(){
  document.getElementById('overlay').innerHTML = '';

      document.getElementById('overlay').className = "hidePopup";
  var child = document.getElementById('overlay');
  var oP = document.getElementById('overlay').parentNode;
        var mP = oP.parentNode;
  mP.removeChild(oP);
  mP.appendChild(child);
  
}

function resizePopup(popupHeight,popupWidth)
{
    document.getElementById('popupContent').style.height = popupHeight + "px";    
    document.getElementById('popupBody').style.height = popupHeight + "px";

    if(document.getElementById('overlay').className.indexOf("showPopup") != -1)
  return;

    document.getElementById('overlay').className = "showPopup";

    YUI().use("overlay", "anim", "plugin", function(Y) {

    /* Animation Plugin Constructor */
    function AnimPlugin(config) {
        AnimPlugin.superclass.constructor.apply(this, arguments);
    }
 
    /* 
     * The namespace for the plugin. This will be the property on the widget, which will 
     * reference the plugin instance, when it's plugged in
     */
    AnimPlugin.NS = "fx";
 
    /*
     * The NAME of the AnimPlugin class. Used to prefix events generated
     * by the plugin class.
     */
    AnimPlugin.NAME = "animPlugin";
 
    /*
     * The default set of attributes for the AnimPlugin class.
     */
    AnimPlugin.ATTRS = {
 
        /*
         * Default duration. Used by the default animation implementations
         */
        duration : {
            value: 0.2
        },
 
        /*
         * Default animation instance used for showing the widget (opacity fade-in)
         */
        animVisible : {
            valueFn : function() {
 
    var host = this.get("host");
                var boundingBox = host.get("boundingBox");
 
                var anim;

    if (Y.UA.ie) {
        anim = new Y.Anim({
                    node: boundingBox,
                    from: { height: 0 },
                    duration: this.get("duration")
      });
    }
    else
    {
    anim = new Y.Anim({
                    node: boundingBox,
                    to: { opacity: 1 },
                    duration: this.get("duration")
                  });
     }
                // Set initial opacity, to avoid initial flicker
                if (!host.get("visible") && !Y.UA.ie) {
                    boundingBox.setStyle("opacity", 0);
                }
 
                // Clean up, on destroy. Where supported, remove
                // opacity set using style. Else make 100% opaque
                anim.on("destroy", function() {
                    if (Y.UA.ie) {
                        //this.get("node").setStyle("opacity", 1);
                    } else {
                        this.get("node").setStyle("opacity", "");
                    }
                });
 
                return anim;
            }
        },
 
        /*
         * Default animation instance used for hiding the widget (opacity fade-out)
         */
        animHidden : {
            valueFn : function() {
    var newAnim;

    if (Y.UA.ie) {
    newAnim = new Y.Anim({
        node: this.get("host").get("boundingBox"),
                    to: { height: 0 },
                    duration: this.get("duration")
      });
    }
    else
    {
    newAnim = new Y.Anim({
        node: this.get("host").get("boundingBox"),
                    to: { opacity: 0 },
                    duration: this.get("duration")
      });  
    }
                return newAnim;
                
            }
        }
    }
 
    /*
     * Extend the base plugin class
     */
    Y.extend(AnimPlugin, Y.Plugin.Base, {
 
        /*
         * Initialization code. Called when the 
         * plugin is instantiated (whenever it's 
         * plugged into the host)
         */
        initializer : function(config) {
            this._bindAnimVisible();
            this._bindAnimHidden();
 
            this.after("animVisibleChange", this._bindAnimVisible);
            this.after("animHiddenChange", this._bindAnimHidden);
 
            // Override default _uiSetVisible method, with custom animated method
            this.doBefore("_uiSetVisible", this._uiAnimSetVisible);
        },
 
        /*
         * Destruction code. Invokes destroy in the individual animation instances,
         * and lets them take care of cleaning up any state.
         */
        destructor : function() {
            this.get("animVisible").destroy();
            this.get("animHidden").destroy();
        },
 
        /*
         * The custom animation method, added by the plugin.
         *
         * This method replaces the default _uiSetVisible handler
         * Widget provides, by injecting itself before _uiSetVisible,
         * (using Plugins before method) and preventing the default
         * behavior.
         */
        _uiAnimSetVisible : function(val) {
            if (this.get("host").get("rendered")) {
                if (val) {
                    this.get("animHidden").stop();
                    this.get("animVisible").run();
                } else {
                    this.get("animVisible").stop();
                    this.get("animHidden").run();
                }
                return new Y.Do.Prevent("AnimPlugin prevented default show/hide");
            }
        },
 
        /*
         * The original Widget _uiSetVisible implementation
         */
        _uiSetVisible : function(val) {
            var host = this.get("host");
            var hiddenClass = host.getClassName("hidden");
            if (!val) {
                host.get("boundingBox").addClass(hiddenClass);
            } else {
                host.get("boundingBox").removeClass(hiddenClass);
            }
        },
 
        /* Sets up call to invoke original visibility handling when the animVisible animation is started */
        _bindAnimVisible : function() {
            var animVisible = this.get("animVisible");
 
            // Setup original visibility handling (for show) before starting to animate
            animVisible.on("start", Y.bind(function() {
                this._uiSetVisible(true);
            }, this));
        },
 
        /* Sets up call to invoke original visibility handling when the animHidden animation is complete */
        _bindAnimHidden : function() {
            var animHidden = this.get("animHidden");
 
            // Setup original visibility handling (for hide) after completing animation
            animHidden.after("end", Y.bind(function() {
                this._uiSetVisible(false);
            }, this));
        }
    });

    var adjustedWidth = popupWidth + 70;
    var adjustedHeight = popupHeight + 64;
 
    // Create a new Overlay instance, and add AnimPlugin with a default duration of 2 seconds
    var overlay = new Y.Overlay({
        srcNode: "#overlay",
        width: adjustedWidth  + "px",
        height: adjustedHeight  + "px",
        visible:false,
        shim:false,
        zIndex:1000,
        plugins : [{fn:AnimPlugin, cfg:{duration:.5}}]
    });

  Y.on("click", function() {
        overlay.hide();
    }, "#closeBtn");

  // Center the overlay in the viewport
  overlay.set("centered", true);
     overlay.render();

   overlay.show();
    

  
  });
}



