/*****************************************************************************/
function CWsfApp()
{
	this.fBrowserVersion = 0;
	this.IsIE = 0;
	
   this.DetectBrowser()
}

/*****************************************************************************/
CWsfApp.prototype.OnBodyLoad = function()
{
   this.ImplementMouseCapture();
   //this.FixPngImages();
}

/*****************************************************************************/
CWsfApp.prototype.DetectBrowser = function()
{
   this.IsIE = false;
   this.fBrowserVersion = 0;
   var s = navigator.userAgent.toLowerCase();
   
   if (s.indexOf("opera")!=-1)
   {
   	// dummy
   }
   else if (s.indexOf("gecko")!=-1)
   {
   	// dummy
   }
   else if (s.indexOf("msie")!=-1)
   {
      this.IsIE = true;
		var aVersion = navigator.appVersion.split("MSIE")
		this.fBrowserVersion = parseFloat(aVersion[1]);
   }
}

/*****************************************************************************/
CWsfApp.prototype.ImplementMouseCapture = function()
{
	if (this.IsIE) return;
	
 	var capture = ["click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout" ]; 

   HTMLElement.prototype.setCapture = function()
   { 
   	if (this._capture != null) return;
   	
		var self = this; 
		var flag = false; 
		
		this._capture = function(e)
		{ 
		   if (flag) return;
		   flag = true; 
		   
		   var event = document.createEvent("MouseEvents"); 
		   
		   event.initMouseEvent(e.type, 
		       e.bubbles, e.cancelable, e.view, e.detail, 
		       e.screenX, e.screenY, e.clientX, e.clientY, 
		       e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 
		       e.button, e.relatedTarget); 

		   self.dispatchEvent(event); 
		   flag = false; 
		}; 
		
		for (var i=0; i<capture.length; i++) 
		{ 
		   window.addEventListener(capture[i], this._capture, true); 
		} 
	}

   HTMLElement.prototype.releaseCapture = function()
   { 
   	if (this._capture == null) return;
   	
   	for (var i=0; i<capture.length; i++) 
   	{ 
      	window.removeEventListener(capture[i], this._capture, true); 
      } 
      
      this._capture = null; 
   }
}

/*****************************************************************************/
CWsfApp.prototype.FixPngImages = function()
{
	if (!this.IsIE || this.fBrowserVersion > 6)  return;
	
   for(var i=0; i<document.images.length; i++)
   {
      this.FixPng(document.images[i]);
   }
}

/*****************************************************************************/
CWsfApp.prototype.FixPng = function(img)
{
	if (!this.IsIE || this.fBrowserVersion > 6) return;
	
   var imgName = img.src.toUpperCase()
	      
   if (imgName.substring(imgName.length-4, imgName.length) == ".PNG" && img.style.filter =="")
   {
		//img.style.width = img.width + "px";
	   //img.style.height = img.height + "px";
	   img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale')";
	   img.src = "wsf/img/t.png";
	}
}

/*****************************************************************************/
g_App = new CWsfApp();

