﻿// 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).style.verticalAlign='top';
            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.paddingLeft=left+'px';
            
            
//            document.getElementById(this.WindowId).style.borderLeftColor="#000000";
//            document.getElementById(this.WindowId).style.borderRightColor="#000000";
//            document.getElementById(this.WindowId).style.borderLeftWidth="1px";
//            document.getElementById(this.WindowId).style.borderRightWidth="1px";
//          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'));

               
	    }
	   
	    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();
        }
        
	 //  setTimeout('OpacityWindow("'+this.WindowId+'",1);',20);
	   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 (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';	     
	    
	}
	this.CloseWindow1=function()
		{
		    if(document.getElementById(this.WindowId)!=null)
		    {
                document.body.removeChild(document.getElementById(this.WindowId));
            }
            if(document.getElementById('_'+this.WindowId)!=null)
            {
                document.body.removeChild(document.getElementById('_'+this.WindowId));
            }
            window.onresize=null;
            window.onscroll=null;
           
            return false;
		}
	

}


	
	
		 function OpacityWindow(id1,opacity)
		{

		       id=id1;
		       document.getElementById(id).style.opacity = opacity;
	           document.getElementById(id).style.filter = 'alpha(opacity=' + opacity + ')';
	           document.getElementById(id).style.MozOpacity=opacity/100;
	           document.getElementById(id).style.visibility='visible';
	           if(opacity<100)
	                setTimeout('OpacityWindow("'+id+'",'+(opacity+20)+');',1);
		}
	 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 (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 fnWindowResize(evt,id)
        {
           window.status=document.getElementById(id+'_Middle').style.display;
          if(document.getElementById(id+'_Middle').style.display!='none')
          {
                
                 var left='';
                left=document.getElementById(id).style.left;
                left=left.substring(0,left.length-2);
               
                 var top='';
                top=document.getElementById(id).style.top;
                top=top.substring(0,top.length-2);
                
                var objResize=document.getElementById(id+'_resize');
                objResize.style.cursor='nw-resize';
                objResize.onmouseout=function(){
                    objResize.style.cursor='pointer';
                }
                objResize.onmousedown=function(){
               
                        document.onmousemove=function(evt) {
                                                document.getElementById(id+'_Table').style.visibility='hidden';
                                                document.getElementById(id).style.backgroundColor='#000000';
                                                document.getElementById(id).style.opacity=50;
                                                document.getElementById(id).style.filter = 'alpha(opacity=' + 50 + ')';
                                                document.getElementById(id).style.MozOpacity=50/100;
                                                
                                                var nav4=window.event?true:false;
                                                var e = window.event ? window.event : evt;
                                                
                                                if (nav4) {
                                                        x = window.event.clientX + document.documentElement.scrollLeft
                                                             + document.body.scrollLeft;
                                                        y = window.event.clientY + document.documentElement.scrollTop +
                                                             + document.body.scrollTop;
                                                }
                                                else {
                                                        x = e.clientX + window.scrollX;
                                                        y = e.clientY + window.scrollY;
                                                }
                                               
                                               
                                               if(navigator.userAgent.indexOf('MSIE')>=0)
                                                    y=y-50;
                                                 
                                                if((y-parseInt(top))>150 || (x-parseInt(left))>150)
                                                {
                                                
                                              
                                              
                                                    document.getElementById(id).style.height=(y-parseInt(top))+'px';
                                                    document.getElementById(id).style.width=(x-parseInt(left))+'px';
                                                   
                                                }
                                            }
                                        
                                        
                        document.onmouseup=function(){
                                                
                                                objResize.style.cursor='pointer';
                                                document.onmouseup=mouseUp;
                                                document.onmousemove=mouseMove;
                                                document.getElementById(id+'_resize').onmousedown=null;
                                                document.getElementById(id+'_Table').style.visibility='visible';

                                                document.getElementById(id).style.backgroundColor='#ffffff';
                                                document.getElementById(id).style.opacity=100;
                                                document.getElementById(id).style.filter = 'alpha(opacity=' + 100 + ')';
                                                document.getElementById(id).style.MozOpacity=100/100;
                                               
                                            }               
             
                    }
             } 
             else
             {
             document.getElementById(id+'_resize').style.cursor='';
             document.getElementById(id+'_resize').onmousedown=null;
             }
       }
       
       
        function MinimizeWindow(divWindow,mode,height1,ss1,ss2)
        {
      
            if(mode=='Y')
            {
                var height=document.getElementById(divWindow).style.height;
                document.getElementById(divWindow+'_Middle').style.display='none';
                document.getElementById(divWindow+'_Minimize').onclick=function() { MinimizeWindow(divWindow,'N',height) };
                document.getElementById(divWindow).style.height='53px';
              
            }
            else
            {
            
                if(navigator.userAgent.indexOf('MSIE')>=0)
                    document.getElementById(divWindow+'_Middle').style.display='block';
                else
                    document.getElementById(divWindow+'_Middle').style.display='table-row';
               
                document.getElementById(divWindow).style.height=height1;
                document.getElementById(divWindow+'_Minimize').onclick=function() { MinimizeWindow(divWindow,'Y') };
            }
        }
      
     
        function  MaximizeWindow(divWindow,mode,x,y,width,height,ZIndex)
        {
            
            if(document.getElementById(divWindow+'_Middle').style.display=='none')
            {
                if(navigator.userAgent.indexOf('MSIE')>=0)
                {
                    document.getElementById(divWindow+'_Minimize').click();
                }
                else
                {
                    document.getElementById(divWindow+'_Middle').style.display='table-row';
                    document.getElementById(divWindow+'_Minimize').onclick=function() { MinimizeWindow(divWindow,'Y') };
                }
            }
            if(mode=='Y')
            {
            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 (nav4) {
                     x =  document.documentElement.scrollLeft + document.body.scrollLeft;
                     y = document.documentElement.scrollTop + document.body.scrollTop;
                }
            else {
                     x =window.scrollX;
                     y = window.scrollY;
                }
               
                var x1=document.getElementById(divWindow).style.left;
                var y1=document.getElementById(divWindow).style.top;
                var width1=document.getElementById(divWindow).style.width;
                var height1=document.getElementById(divWindow).style.height;
                var zIndex1=document.getElementById(divWindow).style.zIndex;
                document.getElementById(divWindow+'_Maximize').onclick=function() {
                MaximizeWindow(divWindow,'N',x1,y1,width1,height1,zIndex1)
                }
                
                document.getElementById(divWindow).style.zIndex='1000000';
                document.getElementById(divWindow).style.left=x+'px';
                document.getElementById(divWindow).style.top=y+'px';
                document.getElementById(divWindow).style.width=bodyWidth+'px';
                document.getElementById(divWindow).style.height=bodyHeight+'px';
                document.getElementById(divWindow+'_Content').style.height='90%';
                
              }
              else
              {
             
                document.getElementById(divWindow).style.left=x;
                document.getElementById(divWindow).style.top=y;
                document.getElementById(divWindow).style.width=width;
                document.getElementById(divWindow).style.height=height;
                document.getElementById(divWindow).style.zIndex=ZIndex;
                document.getElementById(divWindow+'_Content').style.height='80%';
                document.getElementById(divWindow+'_Maximize').onclick=function() {
                MaximizeWindow(divWindow,'Y')
                }
              }  
                
             

        }
		function CloseWindow(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 CloseWindowWithControl(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';		   
		   
		   return false;
		}
		function CloseWindowBox(divWindow,mainDiv)
		{
		   if(document.getElementById(mainDiv)!=null)
		    document.getElementById(mainDiv).style.visibility='hidden';
		    document.getElementById(divWindow).style.visibility='hidden';
		    window.onresize=null;
		    window.onscroll=null;
		    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;
		}
