/*
winOpenerFix ver 1.0 (js part)
copyright 2008 Thomas Frank

This EULA grants you the following rights:

Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.

Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product.

Commercial Use. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT.


*/
winOpenerFix={
	htmlDoc:"winOpenerFix.html",
	updateLinks:function(){	
		Opera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
		Safari=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
		Explorer=(document.all && (!(Opera || Safari)));
		if(Opera || Explorer){return};
		var t=this, l=document.links;
		if(!t.inited){t.init()};
		for(var i=0;i<l.length;i++){
			var f=function(){
				var orgRef=l[i].href;
				var contextmenu=function(){
					this.href=t.htmlDoc+"?"+t.id;
					t.currentLink=orgRef
				};
				var mouseover=function(){
					this.href=orgRef
				};
				if(l[i].winOpenerFixEventsApplied){return};
				t.addEvent(l[i],"contextmenu",contextmenu);
				t.addEvent(l[i],"mouseover",mouseover);
				l[i].winOpenerFixEventsApplied=true
			};
			f()
		}
	},
	loadPage:function(l){
		if(!l){return};
		open(this.currentLink,"winOpenerFixWinName"+l)
	},
	addEvent:function(obj, evType, fn, useCapture){	
		if (obj.addEventListener){
    			obj.addEventListener(evType, fn, useCapture);
    			return true;
  		} else if (obj.attachEvent){
   			 var r = obj.attachEvent("on"+evType, fn);
   			 return r;
  		}
	}, 
	init:function(){
		this.id=new Date().getTime();
		var d=document.createElement('div');
		document.body.appendChild(d);
		d.style.display="none";
		d.innerHTML='<iframe name="winOpenerFixIFrame'+this.id+'" src="'+
			this.htmlDoc+'"></iframe>';
		this.inited=true
	}
};
