﻿// JScript File

if(typeof(Tops) === 'undefined')
    Tops = {};
if(typeof Tops.AjaxLogin == 'undefined')
    Tops.AjaxLogin = {};
Tops.AjaxLogin.RegisterUserWindow = {};


Tops.AjaxLogin.RegisterUserWindow = function Tops$AjaxLogin$RegisterUserWindow()
{
    this.debug = 0;
    this.state = 0;
    this.IE = document.all?true:false;

    this.RegisterUserWindow = null;
    this.resetPasswordLayer = null;
    
    this.bodyUniqueId = undefined;
    this.body = null;
    
    this.IsUserCreated = false;
}


Tops.AjaxLogin.RegisterUserWindow.getInstance = function Tops$AjaxLogin$RegisterUserWindow$getInstance()
{
    if (arguments.length !== 0) throw Error.parameterCount();
    return Tops.AjaxLogin.RegisterUserWindow._instance || null;
}

Tops.AjaxLogin.RegisterUserWindow._initialize = function Tops$AjaxLogin$RegisterUserWindow$_initialize( windowid, properties )
{
    if (Tops.AjaxLogin.RegisterUserWindow.getInstance()) {
        throw Error('Instance Already Exists.  Cannot have multiple instances.');
    }
    Tops.AjaxLogin.RegisterUserWindow._instance = new Tops.AjaxLogin.RegisterUserWindow();
    var obj = Tops.AjaxLogin.RegisterUserWindow.getInstance();
    
    for (var name in properties)
    {
        var val = properties[name];
        obj[name] = val;
    }
    
    obj._initializeInternal( windowid );
}


// -------------- Object Functions ----------------------

function Tops$AjaxLogin$RegisterUserWindow$_initializeInternal(windowid)
{
    this.RegisterUserWindow = document.getElementById(windowid);

    if((this.bodyUniqueId !== undefined))
    {
        this.body = document.getElementById(this.bodyUniqueId);
    }
}

function Tops$AjaxLogin$RegisterUserWindow$prototype$open(location)
{
    var winfo = getWindowInfo();
    
    this.RegisterUserWindow.style.width = (winfo.width - 100) + "px";
    this.RegisterUserWindow.style.height = (winfo.height - 100) + "px";
    this.positionWindow();

    if(this.state === 0){
        var iframestr = '<iframe border="0" id="'+ this.body.id +'_iframe" frameborder="0" src="/toplets/login/RegisterUser.aspx" width="100%" height="100%"></iframe>';
        this.body.innerHTML = iframestr;
    
//        if(document.createElement) {
//            try {
//                var tempiframe=document.createElement('iframe');
//                tempiframe.style.border='0px';
//                tempiframe.style.height='100%';
//                tempiframe.style.width='100%';
//                tempiframe.src = "/toplets/login/RegisterUser.aspx";
//                this.body.appendChild(tempiframe);
//                this.state = 1;
//            } catch(exception) {
//            }
//        }
    }
//    if(location) {
//        if(location == 'window')
//            this.positionWindow();
//    
//    } else
//        this.positionOnMouse();

    this.RegisterUserWindow.style.display = 'block';
}

function Tops$AjaxLogin$RegisterUserWindow$prototype$close()
{
    if(this.IsUserCreated === true)
    {
        document.location.reload(true);
    }
    
    this.RegisterUserWindow.style.display = 'none';
}

function Tops$AjaxLogin$RegisterUserWindow$prototype$positionWindow()
{
    if(this.RegisterUserWindow){
        var w = getWindowInfo();
        
        this.RegisterUserWindow.style.top = (((w.height - this.RegisterUserWindow.style.height.replace('px','')) / 2) + w.scrollY) + "px";
        this.RegisterUserWindow.style.left = (((w.width - this.RegisterUserWindow.style.width.replace('px','')) / 2) + w.scrollX) + "px";
//        
//        this.RegisterUserWindow.style.display = 'inline';
//        
//        var width = 0;
//        var height = 0;
//        if(this.RegisterUserWindow.offsetWidth) {
//            width = this.RegisterUserWindow.offsetWidth;
//            height = this.RegisterUserWindow.offsetHeight;
//        } else if(this.RegisterUserWindow.style.pixelWidth) {
//            width = this.RegisterUserWindow.style.pixelWidth;
//            height = this.RegisterUserWindow.style.pixelHeight;
//        }
//        
//        this.RegisterUserWindow.style.top = ((w.height / 2) - (parseInt(height)/2) + w.scrollY) + "px";
//        this.RegisterUserWindow.style.left = ((w.width / 2) - (parseInt(width)/2) + w.scrollX) + "px";
        
    }
}

function Tops$AjaxLogin$RegisterUserWindow$prototype$userCreated( hasCreated)
{
    if(!hasCreated)
    {
        hasCreated = true;
    }
    
    if(hasCreated === true)
    {
        this.IsUserCreated = true;
    }
}

// ------------ Register Prototypes ----------------------

Tops.AjaxLogin.RegisterUserWindow.prototype = {
    _initializeInternal: Tops$AjaxLogin$RegisterUserWindow$_initializeInternal,
    open: Tops$AjaxLogin$RegisterUserWindow$prototype$open,
    close: Tops$AjaxLogin$RegisterUserWindow$prototype$close,
    positionWindow: Tops$AjaxLogin$RegisterUserWindow$prototype$positionWindow,
    userCreated: Tops$AjaxLogin$RegisterUserWindow$prototype$userCreated
};


// -------------- Generic functions -----------------------

function getWindowInfo()
{
  var o = new Object();
  
  // Window Width and Height  
  if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    o.width = document.documentElement.clientWidth;
    o.height = document.documentElement.clientHeight;
  } else if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    o.width = window.innerWidth;
    o.height = window.innerHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    o.width = document.body.clientWidth;
    o.height = document.body.clientHeight;
  }

  // Scroll
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    o.scrollY = window.pageYOffset;
    o.scrollX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    o.scrollY = document.body.scrollTop;
    o.scrollX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    o.scrollY = document.documentElement.scrollTop;
    o.scrollX = document.documentElement.scrollLeft;
  } else {
    o.scrollY = 0;
    o.scrollX = 0;
  }


  return o;
}