﻿// JScript File
  
    
    function SilverWindow() {
    
    
	    var bottomleft;
	    var bottommid;
	    var bottomright;
	    var left;
	    var right;
	    var topleft;
	    var topmid;
	    var topright;
	    var close;
	    var minimize;
	    var maximize;
	    var WindowId;
	    var ResizeWindow=true;
	    var MaximizeWindow=true;
	    var MinimizeWindow=true;
	    var CloseWindow=true;
	    var TitleofWindow=true;
	    var Modeless=true;
	    var MovableWindow=true;
	    var windowtype;
	    var Center;
	    var IsDynamic;
	    
	    this.ResizeWindow=true;
        this.MaximizeWindow=true;
        this.MinimizeWindow=true;
        this.CloseWindow=true;
        this.TitleofWindow=true;
        this.Modeless=true;    
        this.MovableWindow=true;    
        this.Center=true;
        this.IsDynamic=true;
        this.CreateMainDiv=function(divId,opacity)
    {
        var div=document.createElement('div');
	    div.setAttribute('id',divId);
	    document.body.appendChild(div);
        var maindiv=document.getElementById(divId);
       
        maindiv.style.opacity = opacity;
        maindiv.style.filter = 'alpha(opacity=' + opacity + ')';        
        maindiv.style.MozOpacity=opacity/100;
        
	    var brSize =__getBrowserSize();

	    maindiv.style.width=brSize[0]+'px';
        maindiv.style.height=brSize[1]+'px';
        maindiv.style.left='0px';;
        maindiv.style.top= '0px';
        maindiv.style.backgroundColor='#000000';
        maindiv.style.zIndex=100000;
        maindiv.style.position='absolute';
        
        
    }
	this.CreateWindow=function(id,title,left,top,htmlfordisplay,opacity,width,height)
	{
	    
	    this.WindowId=id;
	    
	    if(document.getElementById(id)==null)
	    {
	       var div=document.createElement('div');
            div.setAttribute('id',this.WindowId);
            document.body.appendChild(div);
           
            var innerHtml='';
            if(this.windowtype=='nuncio')
            {
            this.innerHtml=this.nuncio();
            }
            else if(this.windowtype=='Office2007')
            {
            this.innerHtml=this.Office2007();
            }
            else if(this.windowtype=='alphacube')
            {	                    
                this.innerHtml=this.alphacube();	                       
            }
            else if(this.windowtype=='WindowVistaTemplate')
            {
                this.innerHtml=this.WindowVistaTemplate();    
            }
            
            var c=this.innerHtml.split("@")
           
            for(i=0;i<c.length;i++)
            {
                this.innerHtml=this.innerHtml.replace("@",this.WindowId);
            }
            
             document.getElementById(this.WindowId).innerHTML=this.innerHtml;
            document.getElementById(this.WindowId).style.zIndex='100001';
            document.getElementById(this.WindowId).style.position='absolute';
            document.getElementById(this.WindowId).style.visibility='hidden';
            document.getElementById(this.WindowId).style.width=width+'px';
            document.getElementById(this.WindowId).style.height=height+'px';
            document.getElementById(this.WindowId).style.textAlign='center';
            document.getElementById(this.WindowId+"_Content").innerHTML=htmlfordisplay;
            document.getElementById(this.WindowId).style.overflow='visible';
           
            if(this.TitleofWindow==true)
               document.getElementById(this.WindowId+"_Title").innerHTML=title;
            if(this.MovableWindow==true)    
                makeDraggable(document.getElementById(this.WindowId),document.getElementById(this.WindowId+'_Header'));
                
                
	    }
	    else
	    {
            
            document.getElementById(this.WindowId).style.visibility='visible';
            document.getElementById(this.WindowId).style.width=width+'px';
            document.getElementById(this.WindowId).style.height=height+'px';
            document.getElementById(this.WindowId).style.zIndex='100001';
            document.getElementById(this.WindowId).style.textAlign='center';
            document.getElementById(this.WindowId).style.overflow='visible';
            
       
	    }
	   
	    if(document.getElementById('_'+this.WindowId)==null)
	    {
	     
	      
	        if(this.Modeless==true)
	        {
	            
	            this.CreateMainDiv('_'+id,opacity);
	            window.onresize = function(){ fnMainDivResize(id); };
	            window.onscroll= function(){ fnMainDivResize(id); };
	          
	            fnMainDivResize(id);
	        }
	         
	    }
	    else
	    {
	        document.getElementById('_'+this.WindowId).style.visibility='visible';
	    }
	    document.getElementById(this.WindowId).style.left=left+'px';
        document.getElementById(this.WindowId).style.top=top+'px';
       

	}
	this.DisplayWindow=function()
	{
        document.getElementById(this.WindowId).style.opacity = 100;
        document.getElementById(this.WindowId).style.filter = 'alpha(opacity=' + 1 + ')';
        document.getElementById(this.WindowId).style.MozOpacity=1/100;
        document.getElementById(this.WindowId).style.visibility='visible';
        document.getElementById(this.WindowId).style.display='block';
        document.getElementById(this.WindowId).style.position='absolute';
        document.getElementById(this.WindowId).style.backgroundColor='White';
        
        if(this.Center==true)
        {
            this.CenterWindow();
        }
	   document.getElementById(this.WindowId).style.opacity = 100;
       document.getElementById(this.WindowId).style.filter = 'alpha(opacity=' + 100 + ')';
       document.getElementById(this.WindowId).style.MozOpacity=100/100;
       document.getElementById(this.WindowId).style.visibility='visible';
	    
	   
	}
	this.CenterWindow=function()
	{
	    var brSize =__getBrowserSize();
	    var widthC=brSize[0]/2;
	    var heightC=brSize[1];
	      var nav4=window.event?true:false;
	       if(window.event==null)
		    nav4=true;
           if (nav4) {
                     x =  document.documentElement.scrollLeft + document.body.scrollLeft;
                     y = document.documentElement.scrollTop + document.body.scrollTop;
                }
            else {
                     x =window.scrollX;
                     y = window.scrollY;
                }
	    heightC = heightC-y;
	    heightC=heightC/2;
	    var WWidth='';
        WWidth=document.getElementById(this.WindowId).style.width;
        WWidth=parseInt(WWidth.substring(0,WWidth.length-2))/2;
       
        var Wheight='';
        Wheight=document.getElementById(this.WindowId).style.height;
        Wheight=parseInt(Wheight.substring(0,Wheight.length-2))/2;
        
	    var leftC=widthC-WWidth;
	            
	    var topC=heightC-Wheight + y;
	    
	    document.getElementById(this.WindowId).style.left=leftC+'px';
	    document.getElementById(this.WindowId).style.top=topC+'px';	     
	    
	}
}
	 function __getBrowserSize()
	    {
    	    var bodyWidth = document.documentElement.clientWidth;
    	    var bodyHeight = document.documentElement.clientHeight;
        	
		    var bodyWidth, bodyHeight; 
		    if (self.innerHeight){ // all except Explorer 
		       bodyWidth = self.innerWidth; 
		       bodyHeight = self.innerHeight; 
		    }  else if (document.documentElement && document.documentElement.clientHeight) {
		       // Explorer 6 Strict Mode 		 
		       bodyWidth = document.documentElement.clientWidth; 
		       bodyHeight = document.documentElement.clientHeight; 
		    } else if (document.body) {// other Explorers 		 
		       bodyWidth = document.body.clientWidth; 
		       bodyHeight = document.body.clientHeight; 
		    } 
		   var nav4=window.event?true:false;
		   
		   if(window.event==null)
		    nav4=true;
           if (nav4) {
                     x =  document.documentElement.scrollLeft + document.body.scrollLeft;
                     y = document.documentElement.scrollTop + document.body.scrollTop;
                }
            else {
                     x =window.scrollX;
                     y = window.scrollY;
                }
                
                
            bodyWidth=bodyWidth+x;
            bodyHeight=bodyHeight+y;
            return [bodyWidth,bodyHeight];		
    		
	    }
	function fnMainDivResize(id)
        {
        
            if(document.getElementById('_'+id)!=null)
            {
                var brSize =__getBrowserSize();
		        document.getElementById('_'+id).style.left='0px';
	            document.getElementById('_'+id).style.top='0px';
	            document.getElementById('_'+id).style.width=brSize[0]+'px';
	            document.getElementById('_'+id).style.height=brSize[1]+'px';
	        }
        }
      
		function CloseWindowDiv(divWindow,mainDiv)
		{  
		    if(document.getElementById(mainDiv)!=null)
	    	{
		        document.body.removeChild(document.getElementById(mainDiv));
		    }
    	   
		   window.onresize=null;
		   window.onscroll=null;
		   document.getElementById(divWindow).style.display='none';		   
		   ShowHideCombo('')
		   return false;
		}
		function ShowHideCombo(val)
		{
		    var length = document.forms[0].elements.length;
		    for(i=0; i<=length-1;i++)
	        {	
	          var obj=document.forms[0].elements[i].type;	          	        
	          if(obj)
	          {
	             if(obj=='select-one')
	             {
	              var objname=document.forms[0].elements[i];	          
	              objname.style.display =val;  
	             }
	          }
	        }   
	        return true;
		}
