NW = window.NW || {};
if(typeof(NW.EditOverlay) == "undefined") {

NW.EditOverlay = function(divid) {
     // CLASS VARIABLES //
    this.id = null;
    this.winwidth_max = 902;
    this.$divoverlay = null;
    this.elwidth = null;
    this.elheight = null;   
}

// PUBLIC METHODS ////////////////////////////////////////////
NW.EditOverlay.prototype.init = function (id) {
    var nwthis = this;
    this.id = id;
    this.$divoverlay = $("#"  + this.id + "_overlay");
    this.elwidth = this.$divoverlay.width();
    this.elheight = this.$divoverlay.height();
    
    $("#" + this.id + "_click").hover(
      function () {
        //alert('over');
        $(this).addClass('hover');
      }, 
      function () {
        $(this).removeClass('hover'); 
      }
    );
    
    $("#" + this.id + "_click").click(function(event) {
        //alert('test');
        var winheight = $(window).height();
        var winwidth = $(window).width();
        if(winwidth < nwthis.winwidth_max) winwidth = nwthis.winwidth_max;
        //alert(winwidth + " - " + nwthis.elwidth);
        var leftpos = (winwidth - nwthis.elwidth)/2;
        var toppos = (winheight - nwthis.elheight)/2;
        //alert(leftpos + " - " + toppos); 
        //nwthis.$divoverlay.attr({ top: toppos, left: leftpos }).fadeIn("medium");
        nwthis.$divoverlay.css({ top:toppos, left:leftpos }).fadeIn("medium");
    });
    
    $("#" + this.id + "_close").click(function(event) {
        $("#" + nwthis.id + "_overlay").fadeOut("medium");
    });
 
}


}





$(document).ready(function() {
    
    var ov = new NW.EditOverlay();
    ov.init("tech"); 
	
	var ov2 = new NW.EditOverlay();
    ov2.init("tech2"); 
	
	var ov3 = new NW.EditOverlay();
    ov3.init("tech3");
	
    
});
