﻿//-----Collections-------
var ServiceItems_Windows = new Array();

//-----General-----------
var oForeGround ;
var WinStack = "";
var SelectedWin ="";

function OpenWindow(win_mem)
{
    var Win = document.getElementById(win_mem.WinID);
    if(!Win)
    {
        if (!oForeGround){alert("Set oForeGround");return}
        //oForeGround = document.body
        win_mem.Create(oForeGround);
        AddWinToStores(win_mem);
        SelectedWin=win_mem.WinID;
        OrderWinStack(win_mem.zIndex);
        Win = document.getElementById(win_mem.WinID);
    }
    else
    {
        SelectedWin=win_mem.WinID;
        RestoreWindow(win_mem);
        OrderWinStack(win_mem.zIndex);
    }
    
    
    var DRCell = document.getElementById(win_mem.WinID + "_td_DR");
    DRCell.style.cursor="nw-resize" ;
    var WinTitle = document.getElementById(win_mem.WinID + "_titl_C");
   //Add Movement Resize Events
    if(isIE){
        WinTitle.attachEvent('onmousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","move") });
        DRCell.attachEvent('onmousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","resize") });
        
        document.body.attachEvent('onmouseup',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"up") });
        document.body.attachEvent('onmousemove',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"move") });
        document.body.attachEvent('onmouseout',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"out") });
    }else{
        WinTitle.addEventListener('mousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","move") },false);
        DRCell.addEventListener('mousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","resize") },false);
        
        document.body.addEventListener('mouseup',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"up") },false);
        document.body.addEventListener('mousemove',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"move") },false);
        document.body.addEventListener('mouseout',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"out") },false);
    }
    
}
function CloseWindow(win_mem)
{
    
    //Remove Movement Resize Events
    var WinTitle = document.getElementById(win_mem.WinID + "_titl_C");
    var DRCell = document.getElementById(win_mem.WinID + "_td_DR");
    if(isIE){
        WinTitle.detachEvent('onmousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","move") });
        DRCell.detachEvent('onmousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","resize") });
        
        document.body.detachEvent('onmouseup',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"up") });
        document.body.detachEvent('onmousemove',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"move") });
        document.body.detachEvent('onmouseout',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"out") });
        
    }else{           
        WinTitle.removeEventListener('mousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","move") },false);
        DRCell.removeEventListener('mousedown',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"down","resize") },false);
        
        document.body.removeEventListener('mouseup',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"up") },false);
        document.body.removeEventListener('mousemove',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"move") },false);
        document.body.removeEventListener('mouseout',function(e){var e=e? e : window.event; WinMovementHandle(e,Win,"out") },false);
   }
   
    SelectedWin="";   
    win_mem.Remove(oForeGround);
    RemoveWinFromStores(win_mem);
}

function OrderWinStack(startZ)
{
   if(WinStack==""){return}
   
   var Objs = WinStack.split(",");
   
   for(var i=0; i<Objs.length-1; i++)
   {
       var o = document.getElementById(Objs[i]);
       if (o.id == SelectedWin)
       {
           setFilter_Opacity(o.id + "_tittle", 100);
           o.style.zIndex = startZ + 1; 
       }
       else
       {
           setFilter_Opacity(o.id + "_tittle" , 80);
           o.style.zIndex = startZ;
       }
   }
}
function RestoreWindow(win_mem)
{
    var win = document.getElementById(win_mem.WinID);
    if (WinStack.indexOf(win.id)<0){
        WinStack += win.id + ",";
    }
    
    win_mem.Expand(); //ftiaxnei mono tis diastaseis kai tin thesi tou window
}
function AddWinToStores(win_mem)
{
    ServiceItems_Windows[win_mem.Id]= win_mem;
    if (WinStack.indexOf(win_mem.WinID) < 0) {
        WinStack += win_mem.WinID + ",";
    }
}
function RemoveWinFromStores(win_mem)
{
    ServiceItems_Windows[win_mem.Id] = null;
    if (WinStack.indexOf(win_mem.WinID) >= 0) {
        WinStack = WinStack.replace(win_mem.WinID + ",","");
    }
}




//-------------------------------------------------------
/****CLASS WindowItem MEMBERS*********/
//-------------------------------------------------------
function WindowItem(id,lvl,icon,tittle,content,rect,visibleTitle,isIE,zIndex)
{
    this.Id = id;
    this.WinID = id + "_win_" + lvl;
    this.Icon=icon;
    this.Tittle = tittle;
    this.Content = content;
    this.Rect = rect;
    this.LVL = lvl;
    this.minimized=false;
    this.parentWin;
    this.VisibleTitle = visibleTitle;
    this.zIndex = zIndex;
    this.Create = function(Container)
    {
        
        
        var w = RenderWindow(this, this.LVL, this.Icon, this.Tittle, this.Content, this.Rect);
        Container.innerHTML += w;
        w = document.getElementById(this.WinID);
        
      
        
        AssignStyleToWin(this,Windows_WinStyle);
        FixSizes(this);
        w.style.display="block";
        
        GetWindowContent(w.id,this.Content);
    }
    this.Remove = function(Container)
    {
         var w = document.getElementById(this.WinID);
         

        
        Container.removeChild(w);
        if(this.parentWin){this.parentWin.enable()}
    }
    this.Expand = function()
    {
        this.minimized=false;
        var win = document.getElementById(this.WinID); 
        var tittle = document.getElementById(win.id + "_tittle");
        var btnC = document.getElementById(win.id + "_btn_Close");
        var btnM = document.getElementById(win.id + "_btn_Minimize");
        var cont = document.getElementById(win.id + "_Content");
        
        win.style.display ="block";
        btnC.style.display ="block";
        btnM.style.display ="block";
        cont.style.display ="block";
        
        FixSizes(this);
        
    }
    this.disable = function()
    {
        var win = document.getElementById(this.WinID + '_disable'); 
        setFilter_Opacity(this.WinID + '_disable', 60)
        win.style.display="block";   
    }
    this.enable = function()
    {
         var win = document.getElementById(this.WinID + '_disable');  
        win.style.display="none";
    }
    this.Minimize = function()
    {
        this.minimized=true;
        var win = document.getElementById(this.WinID); 
        var tittle = document.getElementById(win.id + "_tittle");
        var btnC = document.getElementById(win.id + "_btn_Close");
        var btnM = document.getElementById(win.id + "_btn_Minimize");
        var cont = document.getElementById(win.id + "_Content");
        
        btnC.style.display ="none";
        btnM.style.display ="none";
        cont.style.display ="none";
        
        tittle.style.width = (150 - (parseInt(Windows_WinStyle.TR_Width)*2)) + "px"
        win.style.width = "150px";
        win.style.height = Windows_WinStyle.CuttinPoint;
    }
}
function GetWindowContent(winID,content)
{	
	if(content == "" || content == null){return}
	var WinContent = document.getElementById(winID + "_Content")
    
    try{WinContent.appendChild(content)}catch(err){
        try{WinContent.innerHTML=content}catch(error){return}
    };
    //EventWindowLoadEnd(wID)
}


function RenderWindow(win_mem)
{
    var msg = "";
    var winId = win_mem.WinID;
    var lvl = win_mem.LVL
    var icon = win_mem.Icon;
    var tittle = win_mem.Tittle
    var contentPath = win_mem.Content
    var rec = win_mem.Rect
    var vt = win_mem.VisibleTitle
    var z = win_mem.zIndex;
   
   
    
    msg +=" <div id='" + winId + "' style='position: absolute; left: " + rec.x + "px; top: " + rec.y + "px; display: none; z-index:" + z + ";"  ;
    msg +="           width: auto; height: auto; overflow: hidden;' >"
    //msg +="  onmousedown='//WinMovementHandle(event,this,\"down\")' onmousemove='//WinMovementHandle(event,this,\"move\")' "
    //msg +="  onmouseup='//WinMovementHandle(event,this,\"up\")' onmouseout='//WinMovementHandle(event,this,\"out\")' >";
    
    msg +=" <div id='" + winId + "_disable' style='background-color: gray;  z-index:0; position: absolute;   display: none;  "
    msg +="           width: " + (rec.w + 70) +  "px; height: " + (rec.h + 70)+  "px; overflow: hidden;'></div>";
      
    msg +="     <table  style='width: auto; height: auto; display:" + vt + ";' cellspacing='0' cellpadding='0' border='0' >";
    msg +="                    <tr>";
    msg +="                        <td id='" + winId + "_titl_L" + "' UNSELECTABLE='on'  style='width: auto; height: auto; background-repeat: no-repeat;'>";
    msg +="                                 <div  id='" + winId + "_Icon" + "'  style='width: auto; height: auto; background-position: center center; background-image: url(" + icon + "); background-repeat: no-repeat;'></div>"
    msg +="                        </td>";
    msg +="                        <td id='" + winId + "_titl_C" + "' UNSELECTABLE='on'  onclick='tittle_onclick(\"" + win_mem.Id + "\")' style='width: auto; height: auto; background-repeat: repeat-x; vertical-align:bottom;'>";
    msg +="                                ";
    msg +="                                <div id='" + winId + "_tittle' UNSELECTABLE='on' style='width: " + (rec.w) + "px; height: 32px; position: static; overflow:  hidden; vertical-align: bottom; cursor: default;";
    msg +="                                    text-align: left' >";
    msg +="                                    " + tittle ;
    msg +="                                </div>";
    msg +="                                ";
    msg +="                        </td>";
    msg +="                        <td id='" + winId + "_titl_R" + "' style='width: 40px; height: auto; background-position: right top; background-repeat: no-repeat;'>";
    msg +="                            ";
    msg +="                            <table style='width: auto; height: auto' cellspacing='0' cellpadding='0' border='0'>";
    msg +="                                <tr>";
    msg +="                                    <td align='left' valign='top'>";
    msg +="                                         <div id='" + winId + "_btn_Minimize' style='height: 14px; width: 14px; background-repeat: no-repeat;'";
    msg +="                                            onmouseover='MinBtnEventHandler(event,\"over\")'";
    msg +="                                            onmouseout='MinBtnEventHandler(event,\"out\")'";
    msg +="                                            onclick='MinBtnEventHandler(event,\"click\")'>";
    msg +="                                        </div>";
    msg +="                                    </td>";
    msg +="                                    <td align='left' valign='top' >";
    msg +="                                        <div id='" + winId + "_btn_Close' style='height: 14px; width: 14px; background-repeat: no-repeat;'";
    msg +="                                            onmouseover='ClsBtnEventHandler(event,\"over\")'";
    msg +="                                            onmouseout='ClsBtnEventHandler(event,\"out\")'";
    msg +="                                            onclick='ClsBtnEventHandler(event,\"click\")'>";
    msg +="                                        </div>";
    msg +="                                    </td>";
    msg +="                                </tr>";
    msg +="                            </table>";
    msg +="                        </td>";
    msg +="                    </tr>";
    msg +="         </table>";
    msg +="         <table style='width: auto; height: auto' cellspacing='0' cellpadding='0' border='0'>";
    msg +="                 <tr>";
    msg +="                     <td id='" + winId + "_td_UL" + "' style='width: 15px; height: 15px; background-repeat: no-repeat;'></td>";
    msg +="                     <td id='" + winId + "_td_UC" + "' style='width: auto; height: auto; background-repeat: repeat-x; text-align: right' align='right'></td>";
    msg +="                     <td id='" + winId + "_td_UR" + "' style='width: 15px; height: auto; background-repeat: no-repeat;'></td>";
    msg +="                 </tr>";
    msg +="                 <tr>";
    msg +="                     <td id='" + winId + "_td_ML" + "' style='width: 15px; height: auto; background-repeat: repeat-y;'></td>";
    msg +="                     <td runat='server' id='" + winId + "_td_MC" + "' style='width: auto;height: auto;'>";
    msg +="                         <div id='" + winId + "_Content" + "' style='position: block; display: block; ";
    msg +="                             width: " + rec.w + "px; height: " + rec.h + "px; ' ></div>";
    msg +="                     </td>";
    msg +="                     <td id='" + winId + "_td_MR" + "' style='width: 15px;height: auto; background-repeat: repeat-y'></td>";
    msg +="                 </tr>";
    msg +="                 <tr>";
    msg +="                     <td id='" + winId + "_td_DL" + "' style='width: 15px; height: 15px'></td>";
    msg +="                     <td id='" + winId + "_td_DC" + "' style='background-repeat: repeat-x;height: auto;'></td>";
    msg +="                     <td id='" + winId + "_td_DR" + "' style='width: 15px; height: auto; background-repeat: repeat-x;'></td>";
    msg +="                 </tr>";
    msg +="             ";
    msg +="         </table>";
    
    msg +="     </div>";
    
    return msg
}
function tittle_onclick(win_memID)
{
   var win_mem = ServiceItems_Windows[win_memID];
   RestoreWindow(win_mem);
}

var LeftButtonState = "up";
var movePrevPoint ={x:0,y:0}
var moveNextPoint ={x:0,y:0}
var ActiveMovement = false;
var MoveMode;

function WinMovementHandle(e,trig,cmd,mode)
{
    if(ActiveMovement == false && cmd != "down" ){return}
    var ItemID = trig.id.replace(/_win_.*/,"");
    var win_mem = ServiceItems_Windows[ItemID];
    //if(win_mem.minimized){return}
    
    switch(cmd){
        case "down": 
            LeftButtonState = "down";
            ActiveMovement = true;
            MoveMode = mode;
            movePrevPoint = getPosition_Cursor(e);
            
            SelectedWin = trig.id;
            OrderWinStack(win_mem.zIndex);
            break;
        case "move": 
            
            if (LeftButtonState == "down")
            {
              moveNextPoint = getPosition_Cursor(e);
              if (movePrevPoint.x == moveNextPoint.x && movePrevPoint.y == moveNextPoint.y) {return}
               
               var Dx = moveNextPoint.x - movePrevPoint.x;
               var Dy = moveNextPoint.y - movePrevPoint.y;
               
               if(MoveMode=="move"){
                   var objPos = getPosition_Object(trig.id); 
                   //trig.style.left = (objPos.x + Dx) + "px";
                   //trig.style.top = (objPos.y + Dy) + "px";
                   
                   win_mem.Rect.x = (objPos.x + Dx);
                   win_mem.Rect.y = (objPos.y + Dy);
                   
                   //FixSizes(win_mem);
               }else{
                   var container = document.getElementById(trig.id + "_Content");
                   container.style.overflow = "hidden";
                   var s = getObject_Size (container.id);

                   win_mem.Rect.w = Math.abs(s.w + Dx);
                   win_mem.Rect.h = Math.abs(s.h + Dy);
                   
                  // trig.style.width = (300) + "px";
                  // trig.style.height = (300) + "px";
                                  
               }
               FixSizes(win_mem);
               
               movePrevPoint = moveNextPoint;
            }
            break;
                     
        case "up": 
            var container = document.getElementById(trig.id + "_Content");
            container.style.overflow = "auto";
                   
            LeftButtonState = "up";
            ActiveMovement = false;
            MoveMode = "";
            break;
       case "out":
            //LeftButtonState = "up";
            //ActiveMovement = false;
            //MoveMode = "";
            break;
       case "over":
//            var DRCell = document.getElementById(trig.id + "_td_DR");
//            DRCell.style.cursor="s-resize" ;
            break;            
      }
      
      
      e.cancelBubble=true;
}



function ClsBtnEventHandler(e,cmd)
{
    obj = GetEventTrigger(e);
       
    switch(cmd){
        case "over": 
            
            obj.style.backgroundImage= "url(" + Windows_WinStyle.BC_backgroundImage_over  + ")";
            break;
            
        case "click": 
            obj.style.backgroundImage= "url(" + Windows_WinStyle.BC_backgroundImage + ")";
            
            var winID = obj.id.replace("_btn_Close","");
            var ItemID = winID.replace(/_win_.*/,"");
            var win_mem = ServiceItems_Windows[ItemID];// || CustomItems_Windows[ItemID];
            
            //EventPopupClosed(win_mem);
            CloseWindow(win_mem);
           
            //
            break;
        case "out": 
            
            obj.style.backgroundImage= "url(" + Windows_WinStyle.BC_backgroundImage + ")";
            break;
                   
       
        } 
        if(e){e.cancelBubble=true;}
}
function MinBtnEventHandler(e,cmd)
{
//    obj = GetEventTrigger(e);   
//    switch(cmd){
//        case "over": 
//            obj.style.backgroundImage= "url(" + Windows_WinStyle.BM_backgroundImage_over  + ")";
//            break;
//            
//        case "click": 
//            
//            obj.style.backgroundImage= "url(" + Windows_WinStyle.BM_backgroundImage + ")";
//            
//            var winID = obj.id.replace("_btn_Minimize","");
//            var ItemID = winID.replace(/_win_.*/,"");
//            var win_mem = ServiceItems_Windows[ItemID];
//            
//            MinimizeWindow(win_mem);
//            if(e){e.cancelBubble=true;}
//            
//            break;
//        case "out": 
//            obj.style.backgroundImage= "url(" + Windows_WinStyle.BM_backgroundImage + ")";
//            break;
//                   
//       
//        } 
}
function FixSizes(win_mem)
{
    var rect = win_mem.Rect;
    var TL = document.getElementById(win_mem.WinID+ "_titl_L");
    var TR = document.getElementById(win_mem.WinID+ "_titl_R");
    var T = document.getElementById(win_mem.WinID+ "_tittle");
    var ML = document.getElementById(win_mem.WinID+ "_td_ML");
    var MR = document.getElementById(win_mem.WinID+ "_td_ML");
    
    T.style.width = Math.abs(parseInt(ML.style.width)+ parseInt(MR.style.width) + rect.w - parseInt(TL.style.width) - parseInt(TR.style.width)) + "px";
    T.style.height = Math.abs(parseInt(Windows_WinStyle.TITL_Height)) + "px";
    
   var cont = document.getElementById(win_mem.WinID + "_Content");
   cont.style.width = Math.abs(rect.w) + "px";;
   cont.style.height = Math.abs(rect.h) + "px";;
   
   var w = document.getElementById(win_mem.WinID)
   w.style.left = rect.x + "px";
   w.style.top = rect.y + "px";
   w.style.width = Math.abs(rect.w + parseInt(Windows_WinStyle.ML_Width) + parseInt(Windows_WinStyle.MR_Width)) + "px" ;
   w.style.height = Math.abs(rect.h + parseInt(Windows_WinStyle.TL_Height) + parseInt(Windows_WinStyle.UL_Height) + parseInt(Windows_WinStyle.DL_Height) ) + "px";
}

//---------------------Styles---------------------
var Windows_WinStyle = {
    //tittle td Left
    TL_Width: "30px" ,
    TL_Height: "30px" ,
    TL_backgroundImage: "Images_PopUp/popUp_TL.png" ,
    TL_align:'left' ,
    TL_valign:'top' ,
    TL_textAlign:'left' ,
    TL_verticalAlign :'top' ,
    TL_paddingLeft : '0px' ,
    TL_paddingRight : '0px' ,
    TL_paddingTop : '0px' ,
    TL_paddingBottom : '0px' ,
    
    //tittle td Center
    TC_backgroundImage: "Images_PopUp/popUp_TC.png" ,
    
    //tittle td Right
    TR_Width: "40px" ,
    TR_backgroundImage: "Images_PopUp/popUp_TR.png" ,
    TR_align:'left' ,
    TR_valign:'top' ,
    TR_textAlign:'left' ,
    TR_verticalAlign :'top' ,
    TR_paddingLeft : '' ,
    TR_paddingRight : '' ,
    TR_paddingTop : '4px' ,
    TR_paddingBottom : '' ,
    
    //Icon
    Icon_Width: "23px" ,
    Icon_Height: "20px" ,
        
    //-----tittle div----------------------
    CuttinPoint: "23px" ,
    TITL_fontFamily: "Tahoma,Verdana,Arial"	,
    TITL_fontSize: "14px",
    TITL_color: "White",
    TITL_backgroundImage: "none"	,
    TITL_textTransform: "capitalize"	,
    TITL_overflow: "hidden"	,
    TITL_cursor: "deafault" ,
    TITL_Height: "28px" ,
    TITL_align:'left' ,
    TITL_valign:'top' ,
    TITL_textAlign:'left' ,
    TITL_verticalAlign :'top' ,
    TITL_paddingLeft : '3px' ,
    TITL_paddingRight : '' ,
    TITL_paddingTop : '0px' ,
    TITL_paddingBottom : '' ,
    
    
    //--Button Close
    BC_Width: "15px" ,
    BC_Height: "15px" ,
    BC_backgroundImage: "Images_PopUp/popUp_closeButton.png" ,
    BC_backgroundImage_over: "Images_PopUp/popUp_closeButton.png" ,
    
     //--Button minimize
    BM_Width: "15px" ,
    BM_Height: "15px" ,
    BM_backgroundImage: "Images_PopUp/popUp_collapseButton.png" ,
    BM_backgroundImage_over: "Images_PopUp/popUp_collapseButton.png" ,
    
    //td Up Left
    UL_Width: "15px" ,
    UL_Height: "15px" ,
    UL_backgroundImage: "Images_PopUp/popUp_UL.png" ,
    //td Up Center
    UC_backgroundImage: "Images_PopUp/popUp_UC.png" ,
    //td Up Right
    UR_Width: "15px" ,
    UR_backgroundImage: "Images_PopUp/popUp_UR.png" ,
    
    //Content div
    Cont_backgroundColor: "white" ,//"#f0f0f0" ,
    Cont_overflow: "auto" ,
    
    //td Mid Left
    ML_Width: "15px" ,
    ML_backgroundImage: "Images_PopUp/popUp_ML.png" ,
    //td Mid Right
    MR_Width: "15px" ,
    MR_backgroundImage: "Images_PopUp/popUp_MR.png" ,
    
    //td Down Left
    DL_Width: "15px" ,
    DL_Height: "15px" ,
    DL_backgroundImage: "Images_PopUp/popUp_DL.png" ,
    //td Down Center
    DC_backgroundImage: "Images_PopUp/popUp_DC.png" ,
    //td Down Right
    DR_Width: "15px" ,
    DR_backgroundImage: "Images_PopUp/popUp_DR.png" 
    
    
    
};

function AssignStyleToWin(win,le)
{
    //----------TITTLE CELLS
    var item = document.getElementById(win.WinID+ "_titl_L");
    item.style.width = le.TL_Width;
    item.style.height = le.TL_Height;
    item.style.background = "url(" + le.TL_backgroundImage + ")";
    item.style.align = le.TL_align;
    item.style.valign = le.TL_valign;
    item.style.textAlign = le.TL_textAlign;
    item.style.verticalAlign = le.TL_verticalAlign;
    item.style.paddingLeft = le.TL_paddingLeft;
    item.style.paddingRight = le.TL_paddingRight;
    item.style.paddingTop = le.TL_paddingTop;
    item.style.paddingBottom = le.TL_paddingBottom;
    
    item = document.getElementById(win.WinID+ "_titl_C");
    item.style.background = "url(" + le.TC_backgroundImage + ")";
    
    item = document.getElementById(win.WinID+ "_titl_R");
    item.style.width = le.TR_Width;
    item.style.background = "url(" + le.TR_backgroundImage + ")";
    item.style.align = le.TR_align;
    item.style.valign = le.TR_valign;
    item.style.textAlign = le.TR_textAlign;
    item.style.verticalAlign = le.TR_verticalAlign;
    item.style.paddingLeft = le.TR_paddingLeft;
    item.style.paddingRight = le.TR_paddingRight;
    item.style.paddingTop = le.TR_paddingTop;
    item.style.paddingBottom = le.TR_paddingBottom;
    
    //----------ICON
    item = document.getElementById(win.WinID+ "_Icon");
    item.style.width = le.Icon_Width;
    item.style.height = le.Icon_Height;
    
    //----------TITTLE STYLE
    item = document.getElementById(win.WinID+ "_tittle");
    item.style.fontFamily = le.TITL_fontFamily;
    item.style.fontSize  = le.TITL_fontSize;
    item.style.color = le.TITL_color;
    item.style.backgroundImage = le.TITL_backgroundImage;
    item.style.textTransform = le.TITL_textTransform;
    item.style.height = le.TITL_Height;
    item.style.overflow = le.TITL_overflow;
    item.style.cursor = le.TITL_cursor;
    item.style.align = le.TITL_align;
    item.style.valign = le.TITL_valign;
    item.style.textAlign = le.TITL_textAlign;
    item.style.verticalAlign = le.TITL_verticalAlign;
    item.style.paddingLeft = le.TITL_paddingLeft;
    item.style.paddingRight = le.TITL_paddingRight;
    item.style.paddingTop = le.TITL_paddingTop;
    item.style.paddingBottom = le.TITL_paddingBottom;
   
    
    //----------BTN CLOSE
    item = document.getElementById(win.WinID+ "_btn_Close");
    item.style.width = le.BC_Width;
    item.style.height = le.BC_Height;
    item.style.backgroundImage= "url(" + le.BC_backgroundImage + ")";
    
    //----------BTN MINIMIZE
    item = document.getElementById(win.WinID+ "_btn_Minimize");
    item.style.width = le.BM_Width;
    item.style.height = le.BM_Height;
    item.style.backgroundImage = "url(" + le.BM_backgroundImage + ")";
    
    //----------UP
    item = document.getElementById(win.WinID+ "_td_UL");
    item.style.width = le.UL_Width;
    item.style.height = le.UL_Height;
    item.style.background = "url(" + le.UL_backgroundImage + ")";
    
    item = document.getElementById(win.WinID+ "_td_UC");
    item.style.background = "url(" + le.UC_backgroundImage + ")";
    
    item = document.getElementById(win.WinID+ "_td_UR");
    item.style.width = le.UR_Width;
    item.style.background = "url(" + le.UR_backgroundImage + ")";
   
   //---------MID
   item = document.getElementById(win.WinID+ "_td_ML");
   item.style.width = le.ML_Width;
   item.style.background = "url(" + le.ML_backgroundImage + ")";
   
   item = document.getElementById(win.WinID+ "_td_MC");
   item.style.background = "url(" + le.MC_backgroundImage + ")";
   
   item = document.getElementById(win.WinID+ "_td_MR");
   item.style.width = le.MR_Width;
   item.style.background = "url(" + le.MR_backgroundImage + ")";
   
   //----------CONTENT DIV
   item = document.getElementById(win.WinID+ "_Content");
   item.style.backgroundColor = le.Cont_backgroundColor;
   item.style.overflow = le.Cont_overflow;
   //---------DOWN
    item = document.getElementById(win.WinID+ "_td_DL");
    item.style.width = le.DL_Width;
    item.style.height = le.DL_Height;
    item.style.background = "url(" + le.DL_backgroundImage + ")";
    
    item = document.getElementById(win.WinID+ "_td_DC");
    item.style.background = "url(" + le.DC_backgroundImage + ")";
    
    item = document.getElementById(win.WinID+ "_td_DR");
    item.style.width = le.DR_Width;
    item.style.background = "url(" + le.DR_backgroundImage + ")";
}


