﻿//---------------------------------------------------------------------------------
//  (c) 2007 Guardian Networks, Inc
//---------------------------------------------------------------------------------
GNgui.GNPopup = Class.create ( );

GNgui.GNPopup.prototype = 
{
	initialize : function ( ObjNameBase , Parent , X , Y , Wide , High, BorderSize, WindowType)
	{
   	this.ObjNameBase = ObjNameBase;
	  this.ContainerDiv = $ce( 'div' );
	  this.ContainerDiv.Persistent = true;
	  this.ContainerDiv.id = ObjNameBase;
	  //Element.extend ( this.ContainerDiv );
	  this.ContainerDiv.className = "GNguiPopup";
   	this.ContainerDiv.ParentObj = this;
	  this.ContainerDiv.innerHTML = ' ' + 
      '<table id="' + ObjNameBase + 'Table" border="0" cellspacing="0" cellpadding="0" width="100%" class="DetPanelBg">' +
        '<tr>' + 
          '<td width="3" align="left">' +
            '<img src=./' + TARGET + '/images/det_t_l.gif width="3" height="22" border="0">' +
          '</td>' +
          '<td>' +
            '<table id="' + ObjNameBase + 'InnerTable" border="0" cellspacing="0" cellpadding="0" width="100%">' +
              '<tr>' +
                '<td style="background-image:url(./' + TARGET + '/images/det_t.gif);">' +
                  '<span id="' + ObjNameBase + 'Title" class="DetContainerTitleText">Details Panel</span>' +
                '</td>' +
                '<td width="29" align="right" valign="top">' +
                  '<img id="' + this.ObjNameBase + 'Button" src="./' + TARGET + '/images/det_t_close.gif" width="29" height="22" border="0" name="detClose">' +
                '</td>' +
              '</tr>' +
            '</table>' +
          '</td>' +
          '<td width="3" align="right" valign="top">' +
            '<img src="./' + TARGET + '/images/det_t_r.gif" width="3" height="22" border="0">'+
          '</td>' +
        '</tr>' +
        '<tr id="' + this.ObjNameBase + 'ContentRow" height="100%">' +
          '<td width="3" style="background-image:url(./' + TARGET + '/images/det_l.gif);">' +
            '<img src="./' + TARGET + '/images/blank.gif" width="1" height="1" border="0">' +
          '</td>' +
          '<td>' +
            '<div id="' + ObjNameBase + 'Content" class="DetContainerText">' +
            '</div>' +
          '</td>' +
          '<td width="3" style="background-image:url(./' + TARGET + '/images/det_r.gif);">' +
            '<img src="./' + TARGET + '/images/blank.gif" width="1" height="1" border="0">' +
          '</td>' +
        '</tr>' +
        '<tr>' +
          '<td width="3" align="left">' +
            '<img src="./' + TARGET + '/images/det_b_l.gif" width="3" height="3" border="0">' +
          '</td>' +
          '<td style="background-image:url(./' + TARGET + '/images/det_b.gif);">' +
            '<img src="./' + TARGET + '/images/blank.gif" width="1" height="3" border="0">' +
          '</td>' +
          '<td width="3" align="right">' +
            '<img src="./' + TARGET + '/images/det_b_r.gif" width="3" height="3" border="0">' +
          '</td>' +
        '</tr>' +
      '</table>';
	  
	  $ac(Parent,this.ContainerDiv);

    $el(this.ContainerDiv.id,X)
    $et(this.ContainerDiv.id,Y)
    $ew(this.ContainerDiv.id,Wide);
    $eh(this.ContainerDiv.id,High);
   
    this.Button = $e(ObjNameBase+'Button');
    this.Title = $e(ObjNameBase+'Title');
    this.Content = $e(ObjNameBase+'Content');
    
    this.Button.onmouseover = function(){$e(ObjNameBase+'Button').src = './' + TARGET + '/images/det_t_close_over.gif'};
    this.Button.onmouseout = function(){$e(ObjNameBase+'Button').src = './' + TARGET + '/images/det_t_close.gif'};
    this.Button.onmousedown  = function(){$hide(ObjNameBase);return false;};


    Event.observe ( this.ContainerDiv , 'mousedown' , Catch.bindAsEventListener() );
    Event.observe ( this.ContainerDiv , 'mouseup' , Catch.bindAsEventListener() );
    Event.observe ( this.ContainerDiv , 'click' , function(){if (currentScreenName == 'Mapping') Catch.bindAsEventListener()} );
	    	    
	},
  
  AppendChild : function ( obj )
  {
    $ac(this.ObjNameBase+'Content',obj);
    $e(this.ObjNameBase+'ContentRow').style.height = $eh(obj);
    $eh(this.ContainerDiv.id,$eh(obj) + 50);
    $e(obj).style.visibility = 'inherit';
  },
  
  SetTitle : function ( Title )
  {
      $e(this.ObjNameBase+'Title').innerHTML = Title;
  },
  
  GetContentID : function ()
  {
    return this.ObjNameBase + 'Content';
  },
    
  Hide : function ()
  {  
    $hide(this.ContainerDiv);
  },
  
  Show : function ( X , Y)
  {
    if ( X )
    {
      while ( (X + $ew(this.ContainerDiv) ) > $ew(this.ContainerDiv.parentElement))
      {
        X -=2;
      }
      $el(this.ContainerDiv,X);
    }
    if ( Y )
    {
      while ( (Y+$eh(this.ContainerDiv)) > $eh(this.ContainerDiv.parentElement))
      {
        Y -=2;
      }
      $et(this.ContainerDiv,Y);
    }
       
    $show(this.ContainerDiv);
  }
}


