function addEvent(obj, evType, fn){    // Registers events in a cross browser fashion. 
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
   } 
 else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
    }
 else{
      return false;
    }
}
// Global start
var win=null;

// Global end

/*  Child browser window.
Examples for for implementing different child browser sizes:
<a href="targetURL" class="child">Small</a>
*/

function popup(url){
	var properties = "width=700px,height=500px,directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,resizable=yes";
	if (win!=null){   // Close the previously opened window
	 win.close();
	 }	   		
	 win=window.open(url,"child",properties); 	 
     win.focus(); 
	 return win;		
  }
	  
function newWindow (popup){	  
	   if (popup==null || win==null){ alert ('You may have pop up blocker software preventing this window from opening.'); }		
  }
  
  /* Attach onclick events to all child browser opening links */	  
function allLinks(){
	var linkList=document.getElementsByTagName("a");	
	for (var i=0;i<linkList.length;i++){
	   if(linkList[i].className.indexOf("child")>-1){
			linkList[i].onclick=childLinkOnClick;				
		   } 
	   }
  }	  

function childLinkOnClick(){                    // Set the child window size based on the css class value.
   newWindow(popup(this)); 
   return false;		
}

addEvent(window,"load",allLinks);

