﻿// 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;
	    
	    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.initwindow=function(windowtype,ImageDirectory)
        { 
                this.windowtype=windowtype;
               
               if(this.windowtype=='Office2007')
                {
                    if (document.images)
                    {
                    //width x hieght
                      this.bottomleft= new Image(100,25); 
                      this.bottomleft.src=ImageDirectory+"/bottom-left.gif"; // 7 x 7
                      //this.Bottomleft.src="/Office2007/bottom-left.gif" ;
                      this.bottommid= new Image(100,25); 
                      this.bottommid.src=ImageDirectory+"/bottom-mid.gif"; //1 x 7
                      this.bottomright= new Image(100,25); 
                      this.bottomright.src=ImageDirectory+"/bottom-right.gif"; // 7 x 7 
                      this.left= new Image(100,25); 
                      this.left.src=ImageDirectory+"/left.gif"; //7 x 1
                      this.right= new Image(100,25); 
                      this.right.src=ImageDirectory+"/right.gif"; 
                      this.topleft= new Image(100,25); 
                      this.topleft.src=ImageDirectory+"/top-left.gif"; //10 x 25
                      this.topmid= new Image(100,25); 
                      this.topmid.src=ImageDirectory+"/top-mid.gif"; //1 x 25
                      this.topright= new Image(100,25); 
                      this.topright.src=ImageDirectory+"/top-right.gif"; 
                      this.close= new Image(100,25); 
                      this.close.src=ImageDirectory+"/Close.gif"; 
                      this.Maximize= new Image(100,25); 
                      this.Maximize.src=ImageDirectory+"/Maximize.gif"; 
                      this.Minimize= new Image(100,25); 
                      this.Minimize.src=ImageDirectory+"/Minimize.gif"; 
                      this.Restore= new Image(100,25); 
                      this.Restore.src=ImageDirectory+"/Restore.gif"; 
                    }
                    
                }
                
                 
        }
        this.Office2007=function()
    {
        var innerHtml='';
        var s="'";
      
        innerHtml=innerHtml+'<div id=@_Table style="background-color:white;">';
            innerHtml=innerHtml+'<div style="background-image: url(Office2007/top-left.gif); background-repeat: no-repeat;';
                innerHtml=innerHtml+'background-position: left top; height: 30px;">';
                innerHtml=innerHtml+'<div style="background-image: url(Office2007/top-right.gif); background-repeat: no-repeat;';
                    innerHtml=innerHtml+'background-position: right top; height: 30px;">';
                    innerHtml=innerHtml+'<div id=@_Header style="background-image: url(Office2007/top-mid.gif); background-repeat: repeat-x;';
                        innerHtml=innerHtml+'background-position: left top; height: 30px; margin-left: 6px; margin-right: 6px;">';
                        innerHtml=innerHtml+'<table id="HeaderContent" style="height: 100%;" width="100%" cellpadding="0" cellspacing="0"';
                            innerHtml=innerHtml+'border="0">';
                            innerHtml=innerHtml+'<tr>';
                                innerHtml=innerHtml+'<td align="left">';
                                if(this.TitleofWindow==true)
                                {
                                    innerHtml=innerHtml+'<div id="@_Title">';
                                        innerHtml=innerHtml+'Window</div>';
                                }
                                innerHtml=innerHtml+'</td>';
                                innerHtml=innerHtml+'<td align="right" valign="bottom">';
                                if(this.MinimizeWindow==true)
                                    innerHtml=innerHtml+'<img id="@_Minimize" onclick="return MinimizeWindow('+s+'@'+s+','+s+''+'Y'+s+');" src="Office2007/Minimize.gif" alt="" />';
                                if(this.MaximizeWindow==true)
                                    innerHtml=innerHtml+'<img id="@_Maximize" onclick="return MaximizeWindow('+s+'@'+s+','+s+'Y'+s+');" src="Office2007/Maximize.gif" alt="" />';
                                if(this.CloseWindow==true)
                                        innerHtml=innerHtml+'<img id="@_Close" onclick="return CloseWindow('+s+'@'+s+','+s+''+'_@'+s+');" src="Office2007/Close.gif" alt="" /></td>';
                            innerHtml=innerHtml+'</tr>';
                        innerHtml=innerHtml+'</table>';
                    innerHtml=innerHtml+'</div>';
                innerHtml=innerHtml+'</div>';
            innerHtml=innerHtml+'</div>';
            innerHtml=innerHtml+'<div  style="background-image: url('+s+'Office2007/left.gif'+s+'); background-repeat: repeat-y;';
                innerHtml=innerHtml+'background-position: left top; marging-left: 5px;">';
                innerHtml=innerHtml+'<div  style="background-image: url('+s+'Office2007/right.gif'+s+'); background-repeat: repeat-y;';
                    innerHtml=innerHtml+'background-position: right top; marging-left: 5px;">';
                 //   innerHtml=innerHtml+'<div id=@_Middle  style="margin:0px 3px 0px 3px;">';
                        innerHtml=innerHtml+'<div id="@_Content" ></div>';
                  //  innerHtml=innerHtml+'</div>';
                innerHtml=innerHtml+'</div>';
            innerHtml=innerHtml+'</div>';
            innerHtml=innerHtml+'<div id=@_Footer style="background-image: url(Office2007/bottom-left.gif); background-repeat: no-repeat;';
                innerHtml=innerHtml+'background-position: left bottom; height: 23px;">';
                innerHtml=innerHtml+'<div id="@_resize" ';
                if(this.ResizeWindow==true)
                    innerHtml=innerHtml+'onmouseover="fnWindowResize(this,'+s+'@'+s+');" ';
                innerHtml=innerHtml+'style="background-image: url(Office2007/bottom-right.gif); background-repeat: no-repeat;';
                    innerHtml=innerHtml+'background-position: right bottom; height: 23px;">';
                    innerHtml=innerHtml+'<div style="background-image: url(Office2007/bottom-mid.gif); background-repeat: repeat-x;';
                        innerHtml=innerHtml+'background-position: left bottom; height: 23px; margin-left: 6px; margin-right: 6px;">';
                    innerHtml=innerHtml+'</div>';
                innerHtml=innerHtml+'</div>';
            innerHtml=innerHtml+'</div>';
        innerHtml=innerHtml+'</div>';
        
        return innerHtml;
    }
    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=='Office2007')
                        {
                        this.innerHtml=this.Office2007();
                        }
                        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+"_Content").style.width=(width-10)+'px';
                        document.getElementById(this.WindowId+"_Content").style.height=(height+30)+'px';
                        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+"_Content").style.width=(width-10)+'px';
                        document.getElementById(this.WindowId+"_Content").style.height=(height+30)+'px';
                        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(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 = 1;
        document.getElementById(this.WindowId).style.filter = 'alpha(opacity=' + 1 + ')';
        document.getElementById(this.WindowId).style.MozOpacity=1/100;
        document.getElementById(this.WindowId).style.visibility='visible';
        if(this.Center==true)
        {
            this.CenterWindow();
        }
	    setTimeout('OpacityWindow("'+this.WindowId+'",1);',100);
	    document.getElementById(this.WindowId).style.visibility='visible';
	}
	this.CenterWindow=function()
	{
	    var brSize =__getBrowserSize();
	    var widthC=brSize[0]/2;
	    var heightC=brSize[1]/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;
	    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+10)+');',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+'_Content').style.display;
          if(document.getElementById(id+'_Content').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.getElementById(id+'_Content').style.height=(y-parseInt(top)-30)+'px';
                                                    document.getElementById(id+'_Content').style.width=(x-parseInt(left)-10)+'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+'_Content').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+'_Content').style.display='block';
                else
                    document.getElementById(divWindow+'_Content').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+'_Content').style.display=='none')
            {
                if(navigator.userAgent.indexOf('MSIE')>=0)
                {
                    document.getElementById(divWindow+'_Minimize').click();
                }
                else
                {
                    document.getElementById(divWindow+'_Content').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(id+'_Content').style.height=(bodyHeight-30)+'px';
                document.getElementById(id+'_Content').style.width=(bodyWidth-10)+'px';
                
              }
              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(id+'_Content').style.height=height;
                document.getElementById(id+'_Content').style.width=width;
                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(divWindow)!=null)
		    {
		      document.body.removeChild(document.getElementById(divWindow));
		    }
		    if(document.getElementById(mainDiv)!=null)
	    	{
		        document.body.removeChild(document.getElementById(mainDiv));
    	    }
		    window.onresize=null;
		    window.onscroll=null;
		    //decreamentAddedControl();
		    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;
}
