﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("jra");

jra.popUpExtender = function(element) {
    jra.popUpExtender.initializeBase(this, [element]);
    this.fURL       = null;
    this.fWinName   = null;
    this.fFeatures  = null;
    this.fWidth     = null;
    this.fHeight    = null;
    this.fIsCenter  = null;
}

jra.popUpExtender.prototype = {
    initialize: function() {
        jra.popUpExtender.callBaseMethod(this, 'initialize');        
        this.get_element()._onmouseclickHandler = Function.createDelegate(this, this.LinkClicked);
        $addHandlers(this.get_element(), {'click': this.LinkClicked}, this);
        
    },
    dispose: function() {        
        $clearHandlers(this.get_element());
        //Add custom dispose actions here
        jra.popUpExtender.callBaseMethod(this, 'dispose');
    },           
    
    LinkClicked : function(e) {
        if(window.screen)
            if(this.fIsCenter)
                if(this.fIsCenter == "true") {
                    var myLeft       = (screen.width - this.fWidth) / 2;
                    var myTop        = (screen.height - this.fHeight) / 2;
                    this.fFeatures  += (this.fFeatures != "") ? "," : "";
                    this.fFeatures  += ",left=" + myLeft + ",top=" + myTop;
                }
        newwindow = window.open(
            this.fURL, 
            this.fWinName, 
            this.fFeatures + ((this.fFeatures != "") ? "," : "") + "width=" + this.fWidth + ",height=" + this.fHeight);
            
        newwindow.focus();
    },
    
    openPopUp : function(theURL, winName, features, myWidth, myHeight, isCenter) {
        
        
    },
    
    get_URL : function() {
        return this.fURL;
    },
    set_URL : function(value) {
        if(this.fURL != value)
            this.fURL = value;
    },
    
    get_WinName : function(){
        return this.fWinName;
    },
    set_WinName : function(value){
        if(this.fWinName != value)
            this.fWinName = value;
    },
    
    get_Features : function() {
        return this.fFeatures;
    },
    set_Features : function(value){
        if(this.fFeatures != value)
            this.fFeatures = value;
    },
    
    get_Width : function() {
        return this.fWidth;
    },
    set_Width : function(value) {
        if(this.fWidth != value)
            this.fWidth = value;
    },
    
    get_Height : function() {
        return this.fHeight;
    },
    set_Height : function(value) {
        if(this.fHeight != value)
            this.fHeight = value;
    },
    
    get_IsCenter : function() {
        return this.fIsCenter;
    },
    set_IsCenter : function(value) {
        if(this.fIsCenter != value)
            this.fIsCenter = value;
    }
}
jra.popUpExtender.registerClass('jra.popUpExtender', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

