/**** (C)2006 Scripterlative.com

 Info: www.hotspot.freeserve.co.uk/scripterlative 

 These instructions may be removed but not the above text.
 
 Include this script in your page and open windows with the call:

 SmartPop.up("url", "title", "parameter list" [same as window.open] )

 To close a window, use: SmartPop.up("", "title");
 
 When installing inline event handlers, use the syntax:
 
 <a href='#' onclick="return SmartPop.init()" ....>Link</a>
 
 For unobtrusive event handler assignment, apply a valid ID attribute to each triggering link or other element, then use: 
   SmartPop.init(linkId, "url", "title", "parameter list" [same as window.open] );
   
 These calls must be made at any point below the elements to which they refer. There's no need to involve the onload event.
   
 Ensure all windows are given unique titles.  
   
 At the time of writing, Safari (Win) doesn't redisplay windows when their focus method is called.
 
~~~~~~~~~~~~
This code is free however you may donate at www.scripterlative.com.

*** DO NOT EDIT BELOW THIS LINE ***/
   
var SmartPop=
{ 
 winData: {ref:[], title:[]}, 
 
 up:function(locn, wName, paramString) 
 {
    
  wName=wName.replace(/[\s\-]/g, '_');

  for(var j=0, len=this.winData.ref.length; j<len; j++)
   if( this.winData.ref[j].focus && !this.winData.ref[j].closed )
    this.winData.ref[j].self.focus();   
     
  
  for(var i=0, len=this.winData.ref.length; i<len && this.winData.title[i]!=wName ; i++)
  ;
  
  if( i!=len && this.winData.ref[i].focus && !this.winData.ref[i].closed )
   locn!="" ? this.winData.ref[i].focus() : this.winData.ref[i].close();
  else 
   if(locn != "")
    {       
     this.winData.ref[i]=window.open(locn, wName, paramString);
     
     if(!this.winData.ref[i] || this.winData.ref[i].closed || typeof this.winData.ref[i].closed=='undefined')
      alert('This browser is blocking user-requested windows.\n\nPlease change user options.')
     else 
     {
      this.winData.title[i]=wName;
      this.winData.ref[i].focus();
     }
    }
  return false; 
 },
 
 closeAll:function()
 {
  for(var j=0, len=this.winData.ref.length; j<len; j++)
   if( this.winData.ref[j].close && !this.winData.ref[j].closed )
    this.winData.ref[j].close();
  
  return false;          
 },
 
 init:function(elemId)
 {
  var ref=null, args=arguments;   
  if( document.getElementById )
   if( (ref=document.getElementById(elemId)) ) 
    this.addToHandler(ref, 'onclick', (function(a,b,c)
    {
     return function()
     {
      return SmartPop.up(a,b,c);
     }
    })(args[1], args[2], args[3]));       
   else
    alert('There is no element with the ID: '+elemId); 
 },
 
 addToHandler:function(obj, evt, func)
 {
  if(obj[evt])
  {
   obj[evt]=function(f,g)
   {
    return function()
    {
     f.apply(this,arguments);
     return g.apply(this,arguments);
    };
   }(func, obj[evt]);
  }
  else
   obj[evt]=func;
 }
}
/* End of Listing */