function ModelWindow()
{
	ModelWindow.ID = "_BarTab_ModelWindow";
	
	// Flag for WidgetManager.Browser.Opera web browser
	ModelWindow.Browser = new Object();
	ModelWindow.Browser.IE = navigator.userAgent.toLowerCase().indexOf('msie') >= 0 ? true : false;
	ModelWindow.Browser.Opera = navigator.userAgent.toLowerCase().indexOf('opera') >= 0 ? true : false;		
	ModelWindow.Browser.Mozilla = navigator.userAgent.toLowerCase().indexOf('firefox') >= 0 ? true : false;
	ModelWindow.Browser.Netscape = navigator.userAgent.toLowerCase().indexOf('netscape') >= 0 ? true : false;
	
	// Value for Model Window's height and width
	ModelWindow.Height = 200;
	ModelWindow.Width = 200;
	
	// Value for scroll height & width of the page
	ModelWindow.ScrollWidth = document.body.scrollWidth;
	ModelWindow.ScrollHeight = document.body.scrollHeight;
	ModelWindow.Type=1;
			
	ModelWindow.ScrollLeft = typeof( window.pageXOffset ) == "number"? window.pageXOffset : (document.body.scrollLeft? document.body.scrollLeft : document.documentElement.scrollLeft);	
	ModelWindow.ScrollTop = typeof( window.pageYOffset ) == "number"? window.pageYOffset : (document.body.scrollTop? document.body.scrollTop : document.documentElement.scrollTop);
				
	// Value for browser height & width of the page
	ModelWindow.ClientWidth = self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
    if(ModelWindow.Browser.Mozilla)
	{
	  ModelWindow.ClientWidth -= 17;
	}
	ModelWindow.ClientHeight = self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);				
	// Model window layer
	ModelWindow.ModelWindowLayer = null;	
		
	// IFrame window container
	ModelWindow.IFrameContainer = null;
	
	// Model window page url
	ModelWindow.Url = null;
	
	// Model window url frame
	ModelWindow.Frame = null;
	
	ModelWindow.SiteTracker=null;
	
	// Model window url frame
	ModelWindow.HasIFrame = true;
	
	// Model window url frame
	ModelWindow.IgnoreValidation = false;
	
	// Model window call back function
	ModelWindow.CallBackFunction = null;
	
	ModelWindow.IsRendered = false;
	
	// Flag for WidgetManager.Browser.Opera web browser
	ModelWindow.Browser = new Object();
	ModelWindow.Browser.IE = navigator.userAgent.toLowerCase().indexOf('msie') >= 0 ? true : false;
	ModelWindow.Browser.Opera = navigator.userAgent.toLowerCase().indexOf('opera') >= 0 ? true : false;	
	ModelWindow.Browser.Mozilla = navigator.userAgent.toLowerCase().indexOf('fireFox') >= 0 ? true : false;
	ModelWindow.Browser.Netscape = navigator.userAgent.toLowerCase().indexOf('netscape') >= 0 ? true : false;
	
	// Set controls visibility
	ModelWindow.SetControlsVisibility = function(isVisible)
	{
		try
		{
			//Hide all drop down tags
			var dropDownCtrl = document.getElementsByTagName("SELECT");
			var nLength = dropDownCtrl.length;
			for(var nCnt=0; nCnt<nLength; nCnt++)
			{
				dropDownCtrl[nCnt].style.visibility = isVisible == false? "hidden" : "visible";
			}
			dropDownCtrl = null;
			
			//Hide all embed tags
			var embedCtrl = document.getElementsByTagName("EMBED");
			nLength = embedCtrl.length;
			for(var nCnt=0; nCnt<nLength; nCnt++)
			{
				embedCtrl[nCnt].style.visibility = isVisible == false? "hidden" : "visible";
			}
			embedCtrl = null;
			
			//Hide all drop down tags
			var objectCtrl = document.getElementsByTagName("OBJECT");
			nLength = objectCtrl.length;
			for(var nCnt=0; nCnt<nLength; nCnt++)
			{
				objectCtrl[nCnt].style.visibility = isVisible == false? "hidden" : "visible";
			}
			objectCtrl = null;
		}catch(e){}
	};
			
	// Scroll class
	ModelWindow.Scroller = function()
	{		
		try
		{
			// Initalise scroll class
			ModelWindow.Scroller.Init = function()
			{
				if(document.layers)
					{ModelWindow.IFrameContainer.style = ModelWindow.IFrameContainer;}				
				ModelWindow.IFrameContainer.X = ModelWindow.StartX;
				ModelWindow.IFrameContainer.Y = ModelWindow.StartY;			
				ModelWindow.Scroller.PersistPosition();
				new ModelWindow.Scroller.Layer();				
				ModelWindow.Scroller.Layer.Refresh();
			};
			
			// Validation IE compact window validation
			ModelWindow.Scroller.IECompact = function()
			{
				return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
			};		
			
			// Set position of IFrame container window
			ModelWindow.Scroller.SetPosition = function(x, y)
			{
				ModelWindow.IFrameContainer.style.top = y + 30  + "px";			
				ModelWindow.IFrameContainer.style.left = x + "px";			
			};	
				
			// Persist position of IFrame container window
			ModelWindow.Scroller.PersistPosition = function()
			{		
				if(ModelWindow.Browser.IE)
				{
					if(ModelWindow.IFrameContainer)
						{ModelWindow.IFrameContainer.Y += (ModelWindow.Scroller.IECompact().scrollTop + ModelWindow.StartY - ModelWindow.IFrameContainer.Y)/8;}
				}
				else
				{
					if(ModelWindow.IFrameContainer)
						{ModelWindow.IFrameContainer.Y += (ModelWindow.Scroller.IECompact().scrollTop + ModelWindow.StartY - ModelWindow.IFrameContainer.Y)/8;}
				}
					
				if(ModelWindow.IFrameContainer)
				{
                    if(ModelWindow.Type==1)
                    {
                        ModelWindow.Scroller.SetPosition(ModelWindow.IFrameContainer.X, ModelWindow.IFrameContainer.Y);
                        setTimeout("ModelWindow.Scroller.PersistPosition();", 3);
                    }
                    else
                    {
                        ModelWindow.Scroller.SetPosition(ModelWindow.IFrameContainer.X, ModelWindow.IFrameContainer.Y);

                        //setTimeout("ModelWindow.Scroller.PersistPosition();", 0);
                    }				
				}
			};
			
			// Refresh height of opaque layer
			ModelWindow.Scroller.Layer = function()
			{
				ModelWindow.Scroller.Layer.Refresh = function()
				{	
					try
					{
						// Value for scroll height & width of the page
						ModelWindow.ScrollWidth = document.body? document.body.scrollWidth: 0;
						ModelWindow.ScrollHeight = document.body? document.body.scrollHeight: 0;
								
						ModelWindow.ScrollLeft = typeof( window.pageXOffset ) == "number"? window.pageXOffset : (document.body? (document.body.scrollLeft? document.body.scrollLeft : document.documentElement.scrollLeft): 0);	
						ModelWindow.ScrollTop = typeof( window.pageYOffset ) == "number"? window.pageYOffset : (document.body? (document.body.scrollTop? document.body.scrollTop : document.documentElement.scrollTop): 0);
									
						// Value for browser height & width of the page
						ModelWindow.ClientWidth = self.innerWidth || (document.documentElement.clientWidth || (document.body? document.body.clientWidth: 0));
						if(ModelWindow.Browser.Mozilla)
	                    {
	                      ModelWindow.ClientWidth -= 17;
	                    }
						ModelWindow.ClientHeight = self.innerHeight || (document.documentElement.clientHeight || (document.body? document.body.clientHeight: 0));		
								
						if(ModelWindow.ScrollHeight < ModelWindow.ClientHeight)
						{
							if(ModelWindow.Browser.IE || ModelWindow.Browser.Mozilla || ModelWindow.Browser.Netscape)
							{							
								if(ModelWindow.ModelWindowLayer)
									{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ClientHeight + 30 + "px";}
							}
							else
							{
								if(ModelWindow.ModelWindowLayer)
									{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ScrollHeight + 30 + "px";}
							}
						}
						else
						{
							if(ModelWindow.ModelWindowLayer)
								{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ScrollHeight + 100 + "px";}	
						}
						if(ModelWindow.Type==1)	
						setTimeout("if(ModelWindow.Scroller.Layer){ModelWindow.Scroller.Layer.Refresh();}", 1);
					}catch(e){}
				};
			};
		}catch(e){}		
	};
	
	// Render Model window
	ModelWindow.Render = function()
	{	
		try
		{
			// Hide all drop down tags
			ModelWindow.SetControlsVisibility(false);
			
			// Value for layer window's start X and Y position
			ModelWindow.StartX = (ModelWindow.ClientWidth - ModelWindow.Width)/2 - 10;	
			ModelWindow.StartY = (ModelWindow.ClientHeight - ModelWindow.Height)/2 - 50;
						
			// Create opaque layer
			ModelWindow.ModelWindowLayer = document.createElement("DIV");			
			ModelWindow.ModelWindowLayer.style.cssText = "display:block; position:absolute; background:#333333; opacity:0.5; filter:alpha(opacity=70); width:" + ModelWindow.ClientWidth + "px; left:0px; top:0px";		
			ModelWindow.ModelWindowLayer.style.zIndex = 100001;
			if(ModelWindow.ScrollHeight < ModelWindow.ClientHeight)
			{
				if(ModelWindow.Browser.IE || ModelWindow.Browser.Mozilla || ModelWindow.Browser.Netscape)
					{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ClientHeight + 30 + "px";}
				else
					{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ScrollHeight + 30 + "px";}
			}
			else
				{ModelWindow.ModelWindowLayer.style.height = ModelWindow.ScrollHeight + 100 + "px";}
					
			document.body.appendChild(ModelWindow.ModelWindowLayer);
			
			// Check where contains iframe or not
			if(ModelWindow.HasIFrame)
			{	
			   
				ModelWindow.IFrameContainer = document.createElement("DIV");
				ModelWindow.IFrameContainer.className = "DvMnPopup";
				if(!ModelWindow.SiteTracker)
				{
				 ModelWindow.IFrameContainer.style.cssText = "display:block;position:absolute; opacity:1.0; filter:alpha(opacity=100); width:" + ModelWindow.Width + "px;";
				}
				else
				{
				ModelWindow.IFrameContainer.style.cssText = "display:block;position:absolute;width:" + ModelWindow.Width + "px;";
				}
				
				
				ModelWindow.IFrameContainer.style.zIndex = 100002;
				document.body.appendChild(ModelWindow.IFrameContainer);
				
				var dvPopHeader = document.createElement("DIV");
				dvPopHeader.className = "DvPopHeader";
				ModelWindow.IFrameContainer.appendChild(dvPopHeader);
				
				var dvLft1401 = document.createElement("DIV");
				dvLft1401.className = "DvLft1401";
				dvPopHeader.appendChild(dvLft1401);

				var dvRht1401 = document.createElement("DIV");
				dvRht1401.className = "DvRht1401";
				dvPopHeader.appendChild(dvRht1401);
				
				var dvCloseBtn = document.createElement("DIV");
				dvRht1401.appendChild(dvCloseBtn);
				
				var lnkCloseBtn = document.createElement("A"); 
				lnkCloseBtn.className = "CloseBtn";			
				lnkCloseBtn.style.cursor = "pointer";
				lnkCloseBtn.setAttribute("title", "Close");
				lnkCloseBtn.onclick = ModelWindow.Close;
				dvCloseBtn.appendChild(lnkCloseBtn);
				
				var newLine = document.createElement("BR"); 
				newLine.setAttribute("clear", "all");
				dvCloseBtn.appendChild(newLine);
				
				newLine = document.createElement("BR"); 
				newLine.setAttribute("clear", "all");
				dvPopHeader.appendChild(newLine);

				var grayLineTop3 = document.createElement("DIV");
				grayLineTop3.className = "GrayLineTop3";
				dvPopHeader.appendChild(grayLineTop3);
				
				var dvPopMiddle = document.createElement("DIV");
				dvPopMiddle.className = "DvPopMiddle";
				ModelWindow.IFrameContainer.appendChild(dvPopMiddle);
				
				ModelWindow.Frame = document.createElement("IFRAME");
				ModelWindow.Frame.className = "PopupFrame";
				ModelWindow.Frame.frameBorder = "no";
				ModelWindow.Frame.scrolling = "yes";					
				dvPopMiddle.appendChild(ModelWindow.Frame);		
							
				ModelWindow.Frame.setAttribute("src", ModelWindow.Url);
			}
			else
			{
			 	
				// Create object of google map loader
                var loaderImg = document.createElement("img");
                loaderImg.src = BarTab.SiteUrl + "App_Themes/UserThemeNew/Img/Loading.gif";
                
                var loaderSpan = document.createElement("span");
                loaderSpan.innerHTML = "<br/><b><font face='arial' size='2' color='black'>Please wait while loading... </font></b>";
                
				ModelWindow.IFrameContainer = document.createElement("DIV");			
				ModelWindow.IFrameContainer.style.cssText = "display:block; position:absolute; opacity:1.0; filter:alpha(opacity=100); width:" + LayerLoader.Width + "px;";
				ModelWindow.IFrameContainer.appendChild(loaderImg);
				ModelWindow.IFrameContainer.appendChild(loaderSpan);
				ModelWindow.IFrameContainer.style.zIndex = 100002;
				document.body.appendChild(ModelWindow.IFrameContainer);
				
				loaderImg = null;
				loaderSpan = null;
			}		
					  
			ModelWindow.IsRendered = true;
			
			// Initialise scroller class
			new ModelWindow.Scroller();
			ModelWindow.Scroller.Init();
		}
		catch(e)
		{}
		finally
		{
			dvPopHeader = null;
			dvLft1401 = null;
			dvLogo2 = null;
			dvRht1401 = null;
			dvCloseBtn = null;
			lnkCloseBtn = null;
			newLine = null;
			grayLineTop3 = null;
			dvPopMiddle = null;
		}		
	};
	
	// Show model window
	ModelWindow.Show = function()
	{
        try
        {
			if(ModelWindow.IsRendered)
				{ModelWindow.ModelWindowLayer.style.display = ""; }
		}catch(e){}
    };

	// Hide model window
	ModelWindow.Hide = function()
	{
		try
		{
			if(ModelWindow.IsRendered)
				{ModelWindow.ModelWindowLayer.style.display = "none"; }
		}catch(e){}
	};
	
	// Close model window
	ModelWindow.Close = function()
	{
		try
		{
			if(ModelWindow.IsRendered)
			{
				// Destroy model window
				ModelWindow.Destroy();	       
				
				if(ModelWindow.CallBackFunction)
					{ModelWindow.CallBackFunction();}
				
				ModelWindow.CallBackFunction = null;	
			}
		}catch(e){alert(e.message);}
	};
	
	// Destroy model window
	ModelWindow.Destroy = function()
	{			
		try
		{
			if(ModelWindow.IsRendered)
			{
				// Show all drop down tags
				ModelWindow.SetControlsVisibility(true);
				
				// Remove all objects		
				document.body.removeChild(ModelWindow.IFrameContainer);		
				document.body.removeChild(ModelWindow.ModelWindowLayer);
								
				// Nullify all variables
				ModelWindow.ID = null;		
				ModelWindow.StartX = null;
				ModelWindow.StartY = null;
				ModelWindow.Height = null;
				ModelWindow.Width = null;
				ModelWindow.ScrollHeight = null;
				ModelWindow.ScrollWidth = null;
				ModelWindow.ClientHeight = null;
				ModelWindow.ClientWidth = null;
				ModelWindow.ModelWindowLayer = null;
				ModelWindow.IFrameContainer = null;		
				ModelWindow.Url = null;
				ModelWindow.Frame = null;
				ModelWindow.IsRendered = false;
			}
		}catch(e){}		
	};
}
