function NVIQuickModal(){
	/* 
	* This is a class constructor, not a function. You 
	* will have to use the 'new' operator.
	*/
	var _host = this ;
	var _height = 0 ; 
	var _width = 0 ; 
	var _content ;
	var _overlay ;
	var _contentId ;
	var _cachedContent ;
	var _cloneAndRemove = false ;
	var _remove = true ;
	var _overlayAsCloseButton = false ;
	var _overlayStyle = 'myNVIQuickModalOverlay' ; // Should create a method to overwrite this for each instance...
	var _contentStyle = 'myNVIQuickModalContent' ; // Should create a method to overwrite this for each instance...
	var _doc = document.all && document.compatMode == 'BackCompat' ? document.body : document.documentElement ;
	var _cachedSize = { width : 0 , height : 0 } ;
	
	this.setContentId = function( contentId , remove ){
		if( typeof contentId == 'string' ) _contentId = contentId ;
		if( typeof remove == 'boolean' ) _remove = remove ;
	}
	
	this.registerDimension = function( width , height ){
		if( !isNaN( width ) ) _width = width ;
		if( !isNaN( height ) ) _height = height ;
	}
	
	function setStyle( target , property , value ){
		if( typeof target[ property ] != 'undefined' ){
			target[ property ] = value ;
		}else{
			if( typeof target.style[ property ] != 'undefined' ) target.style[ property ] = value ;
		}
	}
	
	this.cloneAndRemove = function(){
		_cloneAndRemove = true ;
	}
	
	function setDimension( target , width , height ){
		void setStyle( target , 'width' , width + "px" ) ;
		void setStyle( target , 'height' , height + "px" ) ;
	}

	function setPosition( target , x , y ){
		void setStyle( target , 'left' , x + "px" ) ;
		void setStyle( target , 'top' , y + "px" ) ;	
	}
	
	function bringToFront( target ){
		void setStyle( target , 'zIndex' , 999999 ) ;	
	}	
	
	function getBodySize(){
		return { 
			width : _doc.scrollWidth , 
			height : _doc.scrollHeight 
		} ;
	}
	function getWindowSize(){
		var result = null ;
		if( typeof window.innerWidth != 'undefined' && window.innerWidth != null ){
			result = { width : window.innerWidth , height:window.innerHeight } ;
		}else{
			result = { width : _doc.clientWidth , height : _doc.clientHeight } ;
		}
		return result ;
	}
	
	function createOverlay(){
		_overlay = document.createElement( 'div' ) ;
		_overlay.className = _overlayStyle ;
		document.body.appendChild( _overlay ) ;
	}
	
	function resizeToWindow(){
		void setDimension( _overlay , 1 , 1 ) ;
		var bProps = getBodySize() ;
		var wProps = getWindowSize() ;
		var width = bProps.width > wProps.width ? bProps.width : wProps.width ;		
		var height = bProps.height > wProps.height ? bProps.height : wProps.height ;
		void setDimension( _overlay , width , height ) ;
	}
	
	function centerContent(){
		var window_dimension = getWindowSize() ;		
		var scrollOffset = getScrollOffset() ;
		var x = 0 , y = 0 ;
		if( _width < window_dimension.width ){
			x = Math.floor( ( window_dimension.width / 2 ) - ( _width / 2 ) ) ;
			if( x < 0 ) x = 0 ;
			x = x + scrollOffset.x ;
		}
		if( _height < window_dimension.height ){
			y = Math.floor( ( window_dimension.height / 2 ) - ( _height / 2 ) ) ;
			if( y < 0 ) y = 0 ;
			y = y + scrollOffset.y ;
		}		
		void setPosition( _content , x , y ) ;
	}
	
	function getScrollOffset(){
		var isIE = document.all || false ;
		var doc = !isIE ? window : document.compatMode !='BackCompat' ? document.documentElement : document.body ;
		return { 
			x : doc[ isIE ? 'scrollLeft' : 'pageXOffset' ] , 
			y : doc[ isIE ? 'scrollTop' : 'pageYOffset' ] 
		} ;	
	}
	
	function addContent(){
		if( typeof _content == 'undefined' || _content == null ){
			try{
				if( _cloneAndRemove ){
					if( typeof _cachedContent == 'undefined' ){
						var targetContent = document.getElementById( _contentId ) ;
						_cachedContent = targetContent.cloneNode( true ) ;
						void removeNode( targetContent ) ;
					}
					_content = _cachedContent ;
				}else{
					_content = document.getElementById( _contentId ).cloneNode( true ) ;
					_content.id = '' ;
				}
				document.body.appendChild( _content ) ;
			}catch( error ){}
		}
	}
	
	function removeNode( node ){
		try{
			node.removeNode( true ) ; 
		}catch( error ){
			try{ 
				node.parentNode.removeChild( node ) ; 
			}catch( error ){}
		}	
	}
	
	function addEventListener( target , eventName , callBack ){
		try{ target.attachEvent( 'on' + eventName , callBack ) ; }
		catch( error ){
			try{ target.addEventListener( eventName , callBack , false ) ; }catch( error ){}
		}
	}
	this.addEventListener = addEventListener ;

	function removeEventListener( target , eventName , callBack ){
		try{ target.detachEvent( 'on' + eventName , callBack ) ; }
		catch( error ){
			try{ target.removeEventListener( eventName , callBack , false ) ; }catch( error ){}
		}	
	}
	this.removeEventListener = removeEventListener ;
	
	this.setOverlayAsCloseButton = function(){
		_overlayAsCloseButton = !_overlayAsCloseButton ;
	}
	this.onOpen ;
	this.onClose ;
	this.open = function(){
		void problematicFlash.initialize() ;
		void problematicFlash.hideElements() ;	
		void createOverlay() ;
		void resizeToWindow() ;
		void setPosition( _overlay , 0 , 0 ) ;
		void addContent() ;
		void setDimension( _content , _width , _height ) ;		
		void setStyle( _content , 'display' , 'block' ) ;
		void centerContent() ;
		void bringToFront( _overlay ) ;
		void bringToFront( _content ) ;
		void addEventListener( window , 'scroll' , centerContent ) ;
		void addEventListener( window , 'resize' , centerContent ) ; 
		void addEventListener( window , 'resize' , resizeToWindow ) ;
		void addEventListener( _overlay , 'click' , _host.close ) ;
		if( typeof _host.onOpen == "function" ) _host.onOpen() ;
	}
	this.close = function(){
		void problematicFlash.showElements() ;
		void removeEventListener( window , 'scroll' , centerContent ) ;
		void removeEventListener( window , 'resize' , centerContent ) ; 
		void removeEventListener( window , 'resize' , resizeToWindow ) ;
		void removeEventListener( _overlay , 'click' , _host.close ) ;
		void removeNode( _overlay ) ;
		void removeNode( _content ) ;
		_overlay = null ;
		_content = null ;
		_cachedSize = { width : 0 , height : 0 } ;
		if( typeof _host.onClose == "function" ) _host.onClose() ;
	}				
}

var problematicFlash = new function(){
	var _count = 0 ;
	var _defaultIdPrefix = "_problematicFlashElement_" ;
	var _collection = {} ;
	var _interval = setInterval( isDocumentReady , 80 );
	function isDocumentReady(){
		try{
			var testNode = document.body.appendChild( document.createElement( 'div' ) ) ;	
			if( typeof testNode == 'undefined' ) throw( 'error' ) ;
			try{ testNode.removeNode( true ) ; } catch( error ) {
				try{ testNode.parentNode.removeChild( testNode ) ; }catch( error ){}
			}
			void clearInterval( _interval ) ;
			void initialize() ;
		}catch( error ){}
	};
	function initialize(){
		void validateObject( document.getElementsByTagName( "embed" ) ) ;					
		void validateObject( document.getElementsByTagName( "object" ) ) ;
	};
	this.initialize = function(){
		void clearInterval( _interval ) ;
		void initialize() ;
	};
	this.hideElements = function(){ manageElements( false ) ; };
	this.showElements = function(){ manageElements( true ) ; };
	function manageElements( display ){
		for( var i  in _collection ){
			try{
				//document.getElementById( i ).style.display = display ? "block" : "none" ;
				document.getElementById( i ).style.visibility = display ? "visible" : "hidden" ;
			}catch( error ){}
		}				
	};
	function validateObject( collection ){
		for( var i = 0 ; i < collection.length ; i++ ){
			var element = collection[ i ] ;
			var nodeName ;
			var type ;
			var classid ;
			try{ type = element.type.toLowerCase() ; }catch( error ){ type = null ; }					
			try{ nodeName = element.nodeName.toLowerCase() ; }catch( error ){ nodeName = null ; }
			try{ classid = element.classid.toLowerCase() ; }catch( error ){ classid = null ; }						
			if( nodeName == 'embed' ){
				if( type != 'application/x-shockwave-flash' ) continue ;
				if( element.parentNode.nodeName.toLowerCase() == 'object' ) continue ;
			}
			if( nodeName == 'object' ){
				if( classid != 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ){
					var haveFlashEmbedAsChild = false ;
					for( var j = 0 ; j < element.childNodes.length ; j++ ){
						var child = element.childNodes[ j ] ;
						var childNodeName ;
						try{ childNodeName = child.nodeName.toLowerCase() ; }catch( error ){ childNodeName = null ; }
						if( childNodeName == 'embed' && child.type == 'application/x-shockwave-flash' ){
							haveFlashEmbedAsChild = true ;
							break ;
						}
					}
					if( !haveFlashEmbedAsChild ) continue ;
				}
			}
			try{
				if( element.getAttribute( 'wmode' ).toLowerCase() == "transparent" ) continue ;
			}catch( error ){}
			var id = element.id ;
			if( id == null || id.match( /\S+/ ) == null ) element.id = id = "_forcedID" + _count ;
			if( typeof _collection[ _defaultIdPrefix + id  ] == 'undefined' ){
				void addWrapper( element , _defaultIdPrefix + id ) ;
				_collection[ _defaultIdPrefix + id  ] = {} ;
				_count++ ;
			}
		}
	};
	function addWrapper( element , id ){
		var container = document.createElement( 'div' ) ;
		container.id = id ;
		element.parentNode.insertBefore( container , element ) ;
		container.appendChild( element ) ;					
	};
};