﻿/**************************************************
 * winmanager.js
 **************************************************
 * This library manages the popup layers
 * drag and drop script is based on the drag and 
 * drop library at www.youngpup.net.
 * by Gokhan Bodur
 **************************************************/

parent.document.onselectstart = function(){return true;};
document.onselectstart = function(){return true;};

var WM = {
    lastZIndex : 0,
	obj : null,
	cloned : null,
	dragged : null,
	timer : null,
	startTop : null,
	startLeft : null,
	snapStep : 0,
	isDraggable : true,
	collapsedAll : false,
    windowHash : new Hashtable(),
    dupeDrag : false,
    _target : null,

    popup : function(target, x, y, w, h)
    {
        
        WM.popupInternal(target, x, y, w, h, false);
        
       
    },
   
    popupLocked : function(target, w, h)
    {
        var x = (parent.document.body.clientWidth - w) / 2;
        var y = (parent.document.body.clientHeight - h) / 2 - 50;
        WM.popupInternal(target, x, y, w, h, true);
        
        
    },
    clearMediaDivContent : function()
    {
   
        var player=document.getElementById('divPlayer'); if(player!=null){player.innerHTML='';} var playerVideo=document.getElementById('divPlayerVideo');  if(playerVideo!=null){playerVideo.innerHTML=''}
    
    }
    ,
    popupInternal : function(target, x, y, w, h, lockbg)
    {
        var id = WM.windowHash.get(target);
        WM.obj = document.getElementById(id);
        WM._target=target;
     
        if(WM.obj == null)
        {
            // create the layer from a template invisible layer.
            WM.obj = document.getElementById("template").cloneNode(1);
            // window ids go like window1, window2..
            WM.obj.id = 'window' + WM.lastZIndex;
            WM.obj.style.position = 'absolute';
            WM.obj.onmouseover = WM.focus;
            // set event handlers for collapse and expand
            //WM.getItem("layerCollapseOn").onclick = WM.collapse;
            WM.getItem("layerCollapse").onclick =function(){WM.collapse();WM.changeTitle(document.getElementById('layerCollapse')); if(target=='{8}'){HideCodeFieldNewMemberTextBox();}  if(target=='{26}'){HideCodeFieldUpdateTextBox();} return false; };
            WM.getItem("layerCollapse1").onclick =function(){WM.collapseW();WM.changeTitle(document.getElementById('layerCollapse1')); if(target=='{8}'){DisplayNewMemberTextBox();}  if(target=='{26}'){DisplayCodeFieldUpdateTextBoxs();} return false;};
 
            WM.getItem("layerClose").onclick = function(){ if(target!='{71}'){WM.callBack('SetCurrentPageIndexNull',['0'],null);} if(target=='{8}'){ HideCodeFieldNewMemberTextBox(); } if(target=='{8}'){WM.closeThis('{23}'); WM.closeThis('{8}');} if(target=='{26}'){HideCodeFieldUpdateTextBox();}if(target=='{25}'){document.getElementById('flashtanitim').innerHTML=''}if(target=='{106}'){document.getElementById('flashmultimedia').innerHTML=''}if(target=='{107}'){document.getElementById('flashvitrin').innerHTML=''} if(target=='{101}'){document.getElementById('konukdetail').innerHTML=''} if(target=='{63}'){document.getElementById('divPlayer').innerHTML=''}if(target=='{70}'){document.getElementById('arkadasimayolla').innerHTML=''}if(target=='{74}'){document.getElementById('arkadasimaoner').innerHTML=''} if(target=='{71}'){document.getElementById('divPlayer2').innerHTML=''} if(target=='{64}'){document.getElementById('divPlayerVideo').innerHTML=''}   WM.close(); return false};
            WM.getItem("layerRefresh").onclick = WM.refresh;
            WM.getItem("layerHeader").ondblclick = WM.collapse;
            
            WM.getItem("layerHeader").onselectstart = function(){return true;};
                      
            if(target=='{33}')
            {
            WM.getItem("layerHeader").onmousedown=function(){WM.isDraggable=false; return true;};
            WM.getItem("layerHeader").style.cursor='default';
            }
            WM.setLocation(x, y, w, h);
            WM.getPageText(target);
            WM.getItem("layerContent").style.display = 'block';
            // add this to the windows hash
            
            WM.windowHash.put(target, WM.obj.id);
            document.body.appendChild(WM.obj);
             WM.initDrag(document.getElementById(WM.obj.id), null, null, null, null, null, false, false, null, null);
        }
         
        if(lockbg)
        {
            WM.lock();
            if(target!='{23}')
            {
              WM.popupInternal=function(){}
              
            }
           
        }
       
        // adjust z-index
        WM.lastZIndex++;
        WM.obj.style.display = 'block';
//        WM.obj.style.display = 'block';
        WM.getItem("layerContent").style.display = 'block';
        WM.getItem("layerContent").style.overflow = 'auto';
        WM.getItem("layerFooter").style.display = 'block';
        WM.obj.style.zIndex = 100 + WM.lastZIndex;
        WM.alloc();
         
         if(target!='{33}')
        {
             
           WM.refresh();
        }
    
    },
   
    
    changeTitle : function(obj)
    {
        if(obj.title=='Pencereyi küçült')
        {
          obj.title=='Pencereyi büyült'
        }
        else
        {
         obj.title=='Pencereyi küçült'
        }
    },
        
        
    // wrapper for page call backs
    callBack : function(name, params, func)
    {
        Anthem_InvokePageMethod(name, params, func);
    },
    
    alloc : function()
    {
        var height = parseInt(WM.obj.style.height) + 125;
        if(WM.getItem("layerContent").style.visibility == 'hidden')
        {
            height = 85;
        }
        var availHeight = parent.document.body.clientHeight;
        if(parseInt(WM.obj.style.top) + height > availHeight && availHeight > height)
        {
            WM.obj.style.top = availHeight - height + "px";
            return true;
        }
        
        if(parseInt(WM.obj.style.left) + parseInt(WM.obj.style.width) > document.body.clientWidth - 5)
        {
            WM.obj.style.left = document.body.clientWidth - 5 - parseInt(WM.obj.style.width) + "px";
            return true;
        }
        
        if(parseInt(WM.obj.style.left) < 5)
        {
            WM.obj.style.left = "5px";
            return true;
        }
        
        if(parseInt(WM.obj.style.top) < 35)
        {
            WM.obj.style.top = "35px";
            return true;
        }
        return false;
    },
    
    setLocation : function(x, y, w, h)
    {
        WM.obj.style.left = x + "px";
        WM.obj.style.top = y + "px";
        WM.obj.style.width = w + "px";
        WM.getItem("layerContent").style.width = w-2 + "px";
        WM.obj.style.height = h - 30 + "px";
        WM.getItem("layerContent").style.height = h + "px";
    },
    
    getPageText : function(target)
    {
        // needs a reference here because call back results are processed asynchronously.
        var newDiv = WM.obj;
        WM.addLoading();
        WM.callBack("GetPageText", [target], 
            function(result) 
            {
                var successful = false;
                if(result.value != null && result.value != 'undefined')
                {
                    var results = result.value.split("<!!>");
                    
                    if(results.length > 1)
                    {
                        WM.getChildItem(newDiv, "layerContent").innerHTML = results[0];
                        WM.getChildItem(newDiv, "layerHeaderImage").src = results[1];
                        successful = true;
                    }
                }
                
                if(!successful)
                {
                    WM.getChildItem(newDiv, "layerContent").innerHTML = "";
                }
            }
        );        
    },
    
    addLoading : function()
    {
        var content = WM.getItem("layerContent");
        var loadingDiv = document.createElement("div");
        loadingDiv.id = "layerLoading";
        loadingDiv.className = "Loading";
        
        var loadingImage = document.createElement("img");
        loadingImage.style.width = "80px";
        loadingImage.style.height = "80px";
        loadingImage.src = "media/shared/wait.gif";
        loadingDiv.style.top = parseInt(WM.obj.style.height) / 2 + 15 + 'px';
        loadingDiv.style.left = parseInt(WM.obj.style.width) / 2 - 31 + 'px';
        loadingDiv.appendChild(loadingImage);
        
        var lockedDiv = document.createElement("div");
        lockedDiv.style.top = '25px';
        lockedDiv.style.left = '1px';
        lockedDiv.style.position = 'absolute';
        lockedDiv.className = 'Locked';
        lockedDiv.style.height = parseInt(WM.obj.style.height) + 30 + 'px';
        lockedDiv.style.width = parseInt(WM.obj.style.width) - 1 + 'px';
        lockedDiv.style.backgroundColor = '#f7e3ef';
        
        content.appendChild(lockedDiv);
        content.appendChild(loadingDiv);
    },
    
    refresh : function()
    {
        var newDiv = WM.obj;
        WM.getPageText(WM.getTarget());
        return false;
    },
    refreshThis : function(target)
    {
        var id = WM.windowHash.get(target);
        WM.obj = document.getElementById(id);
        if(WM.obj!=null)
        {
         var newDiv = WM.obj;
         WM.getPageText(WM.getTarget());
        }
        return false;
    }
    ,
    
    redirect : function(target)
    {
        WM.windowHash.remove(WM.getTarget());
        WM.windowHash.put(target, WM.obj.id);
        WM.getPageText(target);
        return false;
    },
    // opens the popup relative to the top left corner of the caller layer
    popupRelative : function(target, x, y, w, h)
    {
        WM.popup(target, parseInt(WM.obj.style.left) + x, parseInt(WM.obj.style.top) + y, w, h);
    },
    
    item : null,
    // gets an item inside the layer.
    getItem : function(id)
    {
        return WM.getChildItem(WM.obj, id);
    },
    // gets a child item inside the input node
    getChildItem : function(node, id)
    {
        WM.item = null;
        WM.getItemRecursive(node, id);
        return WM.item;
    },
    // recurse to find the item by id.
    getItemRecursive : function(node, id)
    {
        var nodes = node.childNodes;
        for(var i = 0; i < nodes.length; i++)
        {
            if(nodes[i].id && nodes[i].id == id)
            {
                WM.item = nodes[i];
            }
            WM.getItemRecursive(nodes[i], id);
        }
    },
    // removes the layer and the hash entry for that layer
    close : function()
    {
        WM.popupInternal=function(target, x, y, w, h, lockbg)
    {
        var id = WM.windowHash.get(target);
        WM.obj = document.getElementById(id);
        WM._target=target;
     
        if(WM.obj == null)
        {
            // create the layer from a template invisible layer.
            WM.obj = document.getElementById("template").cloneNode(1);
            // window ids go like window1, window2..
            WM.obj.id = 'window' + WM.lastZIndex;
            WM.obj.style.position = 'absolute';
            WM.obj.onmouseover = WM.focus;
            // set event handlers for collapse and expand
            //WM.getItem("layerCollapseOn").onclick = WM.collapse;
            WM.getItem("layerCollapse").onclick =function(){WM.collapse();WM.changeTitle(document.getElementById('layerCollapse')); if(target=='{8}'){HideCodeFieldNewMemberTextBox();}  if(target=='{26}'){HideCodeFieldUpdateTextBox();} return false; };
            WM.getItem("layerCollapse1").onclick =function(){WM.collapseW();WM.changeTitle(document.getElementById('layerCollapse1')); if(target=='{8}'){DisplayNewMemberTextBox();}  if(target=='{26}'){DisplayCodeFieldUpdateTextBoxs();} return false;};
 
            WM.getItem("layerClose").onclick = function(){ if(target!='{71}'){WM.callBack('SetCurrentPageIndexNull',['0'],null);} if(target=='{8}'){ HideCodeFieldNewMemberTextBox(); } if(target=='{8}'){WM.closeThis('{23}'); WM.closeThis('{8}');} if(target=='{26}'){HideCodeFieldUpdateTextBox();}if(target=='{25}'){document.getElementById('flashtanitim').innerHTML=''}if(target=='{107}'){document.getElementById('flashvitrin').innerHTML=''}if(target=='{106}'){document.getElementById('flashmultimedia').innerHTML=''} if(target=='{101}'){document.getElementById('konukdetail').innerHTML=''} if(target=='{63}'){document.getElementById('divPlayer').innerHTML=''}if(target=='{70}'){document.getElementById('arkadasimayolla').innerHTML=''}if(target=='{74}'){document.getElementById('arkadasimaoner').innerHTML=''} if(target=='{71}'){document.getElementById('divPlayer2').innerHTML=''} if(target=='{64}'){document.getElementById('divPlayerVideo').innerHTML=''}   WM.close(); return false};
            WM.getItem("layerRefresh").onclick = WM.refresh;
            WM.getItem("layerHeader").ondblclick = WM.collapse;
            
            WM.getItem("layerHeader").onselectstart = function(){return true;};
                      
            if(target=='{33}')
            {
            WM.getItem("layerHeader").onmousedown=function(){WM.isDraggable=false; return true;};
            WM.getItem("layerHeader").style.cursor='default';
            }
            WM.setLocation(x, y, w, h);
            WM.getPageText(target);
            WM.getItem("layerContent").style.display = 'block';
            // add this to the windows hash
           
            WM.windowHash.put(target, WM.obj.id);
            document.body.appendChild(WM.obj);
            WM.initDrag(document.getElementById(WM.obj.id), null, null, null, null, null, false, false, null, null);
        }
         
        if(lockbg)
        {
            WM.lock();
            WM.popupInternal=function(){}
            
        }
        
        // adjust z-index
        WM.lastZIndex++;
        WM.obj.style.display = 'block';
//        WM.obj.style.display = 'block';
        WM.getItem("layerContent").style.display = 'block';
        WM.getItem("layerContent").style.overflow = 'auto';
        WM.getItem("layerFooter").style.display = 'block';
        
        WM.obj.style.zIndex = 100 + WM.lastZIndex;
        WM.alloc();
         
         if(target!='{33}')
        {
             
           WM.refresh();
        }
    
    }
        
       
        
        WM.removeLock();
        
        if(WM.obj!=null)
        {
        
//        WM.obj.style.visibility = 'hidden';
//        WM.getItem("layerContent").style.visibility = 'hidden';
//        WM.getItem("layerFooter").style.visibility = 'hidden';
        WM.obj.style.display = 'none';
        WM.getItem("layerContent").style.display = 'none';
        WM.getItem("layerFooter").style.display = 'none';
       
        
        }
        
        return false;
    },
    
    lock : function()
    {
        var lockedDiv = document.createElement("div");
        lockedDiv.id = "layerLocked";
        lockedDiv.style.height =1024+ "px";
        lockedDiv.className = "Locked";
        document.body.appendChild(lockedDiv);
        lockedDiv.style.zIndex = WM.lastZIndex + 100;
    },
   
    removeLock : function()
    {
        var layerLocked = document.getElementById('layerLocked');
        if(layerLocked != null)
        {
            document.body.removeChild(layerLocked);
        }
    },
    
    focus : function()
    {
        if(WM.dragged == false || WM.dragged == null || WM.dragged == 'undefined')
        {
            WM.obj = this;
        }
    },   
    
    getTarget : function()
    {
        var values = WM.windowHash.values();
        var keys = WM.windowHash.keys();
        for(var i = 0; i < values.length; i++)
        {
            if(values[i] == WM.obj.id)
            {
                return keys[i];
            }
        }
    },
    
    collapseAll : function()
    {
        var values = WM.windowHash.values();
        
        if(WM.collapsedAll == true)
        {
            for(var i = 0; i < values.length; i++)
            {
                WM.obj = document.getElementById(values[i]);
                if(WM.obj.style.visibility != 'hidden' && WM.getItem("layerContent").style.visibility == 'hidden')
                {
                    WM.collapse();
                }
                WM.collapsedAll = false;
            }
        }
        else
        {
            for(var i = 0; i < values.length; i++)
            {
                WM.obj = document.getElementById(values[i]);
                if(WM.obj.style.visibility != 'hidden' && WM.getItem("layerContent").style.visibility != 'hidden')
                {
                    WM.collapse();
                }
                WM.collapsedAll = true;
            }
        }
    },
   
    ExpandAllW : function()
    {
     var values = WM.windowHash.values();
         if(WM.collapsedAll == true)
       {
          for(var i = 0; i < values.length; i++)
            {
               WM.obj = document.getElementById(values[i]);
               if(WM.obj.style.visibility != 'hidden' && WM.getItem("layerContent").style.visibility == 'hidden')
              {
                    WM.collapse();
                    WM.collapseW(); 
                    
                    if(WM.windowHash.containsKey('{8}'))
                    {
                        var id8=WM.windowHash.get('{8}');
                        WM.obj=document.getElementById(id8);
                        if(WM.obj.style.visibility=='visible')
                        {
                           DisplayNewMemberTextBox();
                        }
                    }
                    
                    if(WM.windowHash.containsKey('{26}'))
                    {
                       var id26=WM.windowHash.get('{26}');
                       WM.obj=document.getElementById(id26);
                       if(WM.obj.style.visibility=='visible')
                       {
                          DisplayCodeFieldUpdateTextBoxs();
                       }
                    }      
              }
                WM.collapsedAll = false;
              
            }
         
              
        }
        
    
    },

    CollapseAllW : function()
    {
        var values = WM.windowHash.values();
        if(WM.collapsedAll == false)
        {
            for(var i = 0; i < values.length; i++)
            {
                WM.obj = document.getElementById(values[i]);
                if(WM.obj.style.visibility != 'hidden' && WM.getItem("layerContent").style.visibility != 'hidden')
                {
                    WM.collapse();
                   
                   
                   if(WM.windowHash.containsKey('{8}'))
                    {
                        var id8=WM.windowHash.get('{8}');
                        WM.obj=document.getElementById(id8);
                        if(WM.obj.style.visibility=='visible')
                        {
                           HideCodeFieldNewMemberTextBox();
                        }
                    }
                    
                    if(WM.windowHash.containsKey('{26}'))
                    {
                       var id26=WM.windowHash.get('{26}');
                       WM.obj=document.getElementById(id26);
                       if(WM.obj.style.visibility=='visible')
                       {
                           HideCodeFieldUpdateTextBox();
                       }
                    }
         
                }
                WM.collapsedAll = true;
            }
        }
    },    
    
    
    
    closeAll : function()
    {
        var values = WM.windowHash.values();
        for(var i = 0; i < values.length; i++)
        {
            WM.obj = document.getElementById(values[i]);
            WM.close();
            HideCodeFieldUpdateTextBox();
            HideCodeFieldNewMemberTextBox();
            
        }
    },
    
    closeThis : function(target)
    {
      
        var id = WM.windowHash.get(target);
        WM.obj = document.getElementById(id);
        
        WM.close();      
           
        
    },
    
    getLocation : function(target)
    {
        var id = WM.windowHash.get(target);
        WM.obj = document.getElementById(id);
       
        var left=WM.obj.style.left; 
        var top=WM.obj.style.top;
        var width=WM.obj.style.width;
        var width2=WM.getItem("layerContent").style.width;
        var height=WM.obj.style.height;
        var height2=WM.getItem("layerContent").style.height;
        
    },    
    

    
    // collapse event handler
    collapseW : function()
    {
        WM.collapseItemW(WM.getItem('layerContent'));
        WM.collapseItemW(WM.getItem('layerFooter'));
        WM.alloc();

        return false;
    },
    
    collapseItemW : function(item)
    {
        //if(item.style.visibility == '' || item.style.visibility == 'visible')
            //item.style.visibility = 'hidden';
        //else
            item.style.visibility = 'visible';
    },
    
    
    collapse : function()
    {
        WM.collapseItem(WM.getItem('layerContent'));
        WM.collapseItem(WM.getItem('layerFooter'));
        
        WM.alloc();

        return false;
    },
    
    collapseItem : function(item)
    {
        //if(item.style.visibility == '' || item.style.visibility == 'visible')
            item.style.visibility = 'hidden';
            
        //else
            //item.style.visibility = 'visible';
    },
    
    
    setVisibility : function(obj, isVisible)
    {
        document.getElementById(obj).style.visibility = isVisible ? 'visible' : 'hidden';        
    },
    
    getValue : function(id)
    {
        var obj = document.getElementById(id);
        if(obj)
        {
            if(obj.options)
            {
                return obj.options[obj.selectedIndex].value;
            }
            else if(obj.type == 'radio')
            {
                var commom = obj.id
                var i = 0;
                do
                {
                    var append = (i == 0 ? '' : i);
                    if(document.getElementById(obj.id + append) && document.getElementById(obj.id + append).checked)
                    {
                        return document.getElementById(obj.id + append).value;
                    }
                    i++;
                }while(document.getElementById(obj.id + append))
            }
            else if(obj.type=='checkbox')
            {
                return obj.checked;
            }
            else
            {
                return obj.value;
            }
        }
        return '';
    },
    
    getText : function(id)
    {
        var obj = document.getElementById(id);
        if(obj)
        {
           return obj.Text;
        }
        return '';
    }
    ,
    
    getOptionText : function(id)
    {
       var obj = document.getElementById(id);           
       if(obj)
        {
           var index=obj.selectedIndex; 
           
           return obj.options[index].text;
        }
        return '';
    }
    ,
    
    setOptionText : function(idobj,idobj2)
    {
       var obj = document.getElementById(idobj);           
       if(obj)
        {
           var value=obj.value;
           if(obj.value!='90')
           {
            var obj2=document.getElementById(idobj2);
            if(obj2)
            {
                while(obj2.lenght>1)
                obj2.lenght=1;
                obj2.options[0].value="-1"
                obj2.options[0].text="Out Of Türkiye";
            }
           }
           
          
        }
   
    }
    ,

    
    
    // re-init the page on reload.
    pageLoad : function()
    {
        Anthem_InvokePageMethod("GetIsAuthenticated", [], 
            function(result) 
            {
                var isAuthenticated = result.value;
                WM.setVisibility('register', !isAuthenticated);
                WM.setVisibility('LogoutLink', isAuthenticated);
                WM.setVisibility('LoginLink', !isAuthenticated);
            } 
        );
        WM.load();
    },
    
    pageUnload : function()
    {
        WM.save();
    },
    
    // save the window states to a cookie
    save : function()
    {
        var keys = WM.windowHash.keys();
        var values = WM.windowHash.values();
        var cookieText = '';
        for(var i = 0; i < keys.length; i++)
        {
            WM.obj = document.getElementById(values[i]);
            if(WM.obj)
            {
                try
                {
                    cookieText = cookieText + keys[i] + "," + WM.obj.style.left + "," + WM.obj.style.top + "," + 
                    WM.getItem("layerContent").style.width + "," + WM.getItem("layerContent").style.height + "," + 
                    WM.obj.style.zIndex + ',' + ((WM.getItem("layerContent").style.visibility == 'hidden') ? '0' : '1') + "," + ((WM.obj.style.visibility == 'hidden') ? '0' : '1');
                }
                catch(e)
                {
                }
            }
            if(i != values.length-1)
            {
                cookieText = cookieText + ",";
            }
        }
        SetCookie("windowstates", cookieText);
    },
    
    load : function()
    {
        if(GetCookie("windowstates") != 'undefined' && GetCookie("windowstates") != null)
        {
            var states = GetCookie("windowstates").split(',');
            for(var i = 0; i < states.length; i=i+8)
            {
                if(states[i] != '')
                {
                    WM.popup(states[i], parseInt(states[i+1]), parseInt(states[i+2]), parseInt(states[i+3]), parseInt(states[i+4]));
                    if(parseInt(states[i+5] > 0))
                    {
                        WM.obj.style.zIndex = parseInt(states[i+5]);
                    }
                    WM.getItem("layerContent").style.visibility = states[i+6] == '0' ? 'hidden' : 'visible';
                    WM.getItem("layerFooter").style.visibility = states[i+6] == '0' ? 'hidden' : 'visible';
                    WM.obj.style.visibility = states[i+7] == '0' ? 'hidden' : 'visible';
                }
            }
        }
    },
    
    initDrag : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= WM.startDrag;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
		
		dragged = false;
	},

	startDrag : function(e)
	{
        var o = WM.obj = this;
            
        if(WM.obj.style.zIndex != WM.lastZIndex)
        {
            WM.lastZIndex++;
        }
        WM.obj.style.zIndex = 100 + WM.lastZIndex;
        
	    if(WM.isDraggable)
	    {
            e = WM.fixE(e);
            var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
            var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
            o.root.onDragStart(x, y);
            
            // added
            if(!dragged)
            {
                if(WM.dupeDrag)
                {
	                WM.cloned = WM.obj.cloneNode(0);
	                WM.cloned.innerHTML = WM.obj.innerHTML;
	                WM.cloned.id = WM.obj.id + 'Cloned';
	                WM.cloned.onmouseover = null;
	                WM.cloned.style.zIndex = WM.lastZIndex;
	                WM.obj.className += ' transparent';
	                document.body.appendChild(WM.cloned);
	            }
	            WM.dragged = true;
            }
            //

            o.lastMouseX	= e.clientX;
            o.lastMouseY	= e.clientY;

            if (o.hmode) {
	            if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
	            if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
            } else {
	            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
	            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
            }

            if (o.vmode) {
	            if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
	            if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
            } else {
	            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
	            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
            }

            document.onmousemove	= WM.drag;
            document.onmouseup		= WM.endDrag;

		    return false;
		}
	},
	
	isOutside : function(x, y)
	{
	    return (x < parseInt(WM.obj.style.left) || x > parseInt(WM.obj.style.left) + parseInt(WM.obj.style.width) || 
	    y < parseInt(WM.obj.style.top) || y > parseInt(WM.obj.style.top) + parseInt(WM.obj.style.height));
	},

	drag : function(e)
	{
	    if(WM.isDraggable)
	    {
	        if(document.getElementById('layerLocked') != null)
	        {
	            return false;
	        }
	        
		    e = WM.fixE(e);
		    var o = WM.obj;

		    var ey	= e.clientY;
		    var ex	= e.clientX;
		    
		    try
		    {
	            var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
	            var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
	            var nx, ny;

	            if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
	            if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
	            if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
	            if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

	            nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
	            ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

	            if (o.xMapper)		nx = o.xMapper(y)
	            else if (o.yMapper)	ny = o.yMapper(x)

	            WM.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
	            WM.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
	            WM.obj.lastMouseX	= ex;
	            WM.obj.lastMouseY	= ey;
	            
	            WM.obj.root.onDrag(nx, ny);
	            WM.alloc();
		    }
		    catch(e)
		    {
		    }
		}
		return false;
	},

	endDrag : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		try
		{
		    WM.obj.root.onDragEnd(	parseInt(WM.obj.root.style[WM.obj.hmode ? "left" : "right"]), 
									    parseInt(WM.obj.root.style[WM.obj.vmode ? "top" : "bottom"]));

            if(WM.dupeDrag)
            {    		
		        document.body.removeChild(WM.cloned);
		        var css = WM.obj.className;
		        var i = css.indexOf('transparent');
		        WM.obj.className = css.substring(0, i);
		    }
    		
		    WM.dragged = false;
		    //WM.chooseSnap();
		}
		catch(e)
		{
		}
	},
	
	chooseSnap : function()
	{
		var snapArray = [[600,600], [500,500],[300,300]];
		
		var left = parseInt(WM.obj.style.left);
		var top = parseInt(WM.obj.style.top);
		
		var calculations = new Array();
		
		for(var i = 0; i < snapArray.length; i++)
		{
			var leftDif = left - snapArray[i][0];
			var topDif = top - snapArray[i][1];
			calculations[i] = Math.sqrt(Math.pow(leftDif,2) + Math.pow(topDif,2));
		}
		
		var smallest;
		var smallestValue = 74166799999;
		
		for(var i = 0; i < calculations.length; i++)
		{
			if(smallestValue > calculations[i])
			{
				smallestValue = calculations[i];
				smallest = i;
			}
		}
		
		WM.snap(snapArray[smallest][0], snapArray[smallest][1]);
	},
	
	snap : function(pLeft, pTop)
	{
		var totalStep = 30;
		var left = parseInt(WM.obj.style.left);
		var top = parseInt(WM.obj.style.top);
		
		if(WM.startLeft == null)
		{
			WM.startLeft = left;
		}
		if(WM.startTop == null)
		{
			WM.startTop = top;
		}

		WM.obj.style.left = left - ((WM.startLeft - pLeft)/totalStep) + 'px';
		WM.obj.style.top = top - ((WM.startTop - pTop)/totalStep) + 'px';
		WM.snapStep++;
		if(WM.snapStep != totalStep)
		{
			timer = setTimeout("WM.snap("+ pLeft + "," + pTop+");", 1);
		}
		else
		{
			WM.snapStep = 0;
			WM.startLeft = null;
			WM.startTop = null;
			clearTimeout(timer);
		}
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	},
	
	getValueAndPopup : function(target1,id,x, y, w, h)
    {
        
        var target=target1+'?CID='+id.title;
        WM.popup(target,x,y,w,h); 
       
      
    },
    getValueAndPopup2 : function(target1,id,x, y, w, h)
    {
        
        var target=target1+'?CID='+id;
        WM.popup(target,x,y,w,h); 
       
      
    },
    
    printPage : function(target)
    {
             
             
       
        var id = WM.windowHash.get(target);

        WM.obj = document.getElementById(id);
        var newDiv=WM.obj;
        var html=WM.getItem("layerContent").innerHTML;
        var yenihtml,i,k,yenihtml1;
       if(target=='{11}')
       {              
            for(i=0;i<50;i++)
            {
               yenihtml=html.replace("onclick","");
               html=yenihtml;
            }
            for(k=0;k<50;k++)
            {
               yenihtml1=html.replace("CURSOR","");
               html=yenihtml1;
            }
       }
       if(navigator.appName=="Microsoft Internet Explorer")
       {
           for(z=0;z<50;z++)
           {
              yenihtml=html.replace("class=AlbumDetayBaslik","style=\"color:rgb(94,11,85);padding-bottom:6px; font-weight:bold\"");
              html=yenihtml;
           }
           for(r=0;r<50;r++)
           {
             yenihtml=html.replace("class=Basliklar","style=\"color:rgb(94,11,85); font-weight:bold\"");
             html=yenihtml;
           }
           for(m=0;m<50;m++)
           {
             yenihtml=html.replace("class=NewsBaslikTarih style=\"","style=\"font-family:Tahoma;font-style:italic;font-size:11px;padding-top:6px; padding-bottom:6px;color:#8f0165;text-decoration:none;FONT-WEIGHT:normal;");
             html=yenihtml;
           }
       }
       else
       {
          for(z=0;z<50;z++)
          {

             yenihtml=html.replace("class=\"AlbumDetayBaslik\"","style=\"color:rgb(94,11,85);padding-bottom:6px; font-weight:bold\"");
             html=yenihtml;
          }
         for(r=0;r<50;r++)
           {
              yenihtml=html.replace("class=\"Basliklar\"","style=\"color:rgb(94,11,85); font-weight:bold\"");
              html=yenihtml;
           }
         for(m=0;m<50;m++)
           {
              yenihtml=html.replace("normal;\" class=\"NewsBaslikTarih\"","font-family:Tahoma;font-style:italic;font-size:11px;padding-top:6px; padding-bottom:6px;color:#8f0165;text-decoration:none;FONT-WEIGHT:normal;");
              html=yenihtml;
           }
       
       }
        html="<span style=\"font-family:Arial;color:rgb(94,11,85); font-size:13px; font-weight:bold;\">"+"Sezen Aksu Official Website - www.sezenaksu.com.tr"+"</span>"+"<hr style=\"color:rgb(94,11,85); height:1px;\" />"+"<SPAN style=\"FONT-SIZE: 11px\">"+html+"</SPAN>";
        var printWin = window.open("",'name','height=500,width=455,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        
        printWin.document.open();
        
        printWin.document.write('<style type="text/css">.YazdirmaBaslik{ font-weight:bold }</style>');
       
        printWin.document.write('<style type="text/css">.ButonlarClass{ visibility:hidden }</style>');
       
        printWin.document.write(html);
       
        printWin.document.close();
       
        printWin.print();
    

    },
    
    
    
   genisleyenPencere :function(adres)
{

//if (document.all) 
//{
// var genislikYap = 800;
// var genislikArtir = 8;
// var yukseklikYap =600;
// var yukseklikArtir = 8;
// 
// var yeniPencere =window.open("","","left=30,top=10,width=1,height=1,scrollbars=yes");
// 
// for (yukseklik = 1; yukseklik < yukseklikYap;yukseklik += yukseklikArtir) 
// {
// yeniPencere.resizeTo("1", yukseklik);
// }
// 
// for (genislik = 1; genislik < genislikYap;genislik += genislikArtir) 
// {
// yeniPencere.resizeTo(genislik, yukseklik);
// }
// 
// yeniPencere.location = adres;
//}

//else
//{
 window.open(adres, "urunler","left=150,top=140,width=500,height=700,directories=0,scrollbars=0");
//}

},
    
    
    
    GetTargetAndLocation : function()
    {
        
        var targetAndLocation='';
        var keys=WM.windowHash.keys();
        for(var i = 0; i < keys.length; i++)
        {
            
            var id = WM.windowHash.get(keys[i]);
            WM.obj = document.getElementById(id);
            
            
            if(WM.obj!=null && WM.obj.style.display != 'none')
            {
                var target=keys[i];
                //if(target!='{32}' && target!='{29}'&& target!='{15}'&& target!='{18}'&& target!='{12}'&& target!='{13}'&& target!='{17}'&& target!='{38}'&& target!='{37}'&& target!='{10}'&& target!='{19}'&& target!='{30}'&& target!='{42}'&& target!='{4}'&& target!='{5}'&& target!='{33}'&& target!='{6}'&& target!='{25}'&& target!='{23}'&& target!='{45}'&& target!='{3}') continue;
                var x=WM.obj.style.left.replace("px","");
                var y=WM.obj.style.top.replace("px","");
                var w=WM.obj.style.width.replace("px","");
                var h=WM.getItem("layerContent").style.height.replace("px","");
                
                targetAndLocation=targetAndLocation+'\''+target+'\','+x+','+y+','+w+','+h+';';
            
            }
        }
        return targetAndLocation;
    }
    
    
               
	
};

function SetCookie(sName, sValue)
{
    var date = new Date();
    date.setDate(date.getDate() + 7);
    document.cookie = sName + "=" + escape(sValue) + "; expires=" + date;
}




function GetCookie(sName)
{
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
      // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) 
        return unescape(aCrumb[1]);
    }

    // a cookie with the requested name does not exist
    return null;
}

function getCurrentPageIndex()
{
  var currentPageIndex ='';
  if(currentPageIndex!=null)
  return currentPageIndex;
  return 0;  
}
function HideCodeFieldNewMemberTextBox()
{

    
   var CellPhoneFieldAreaCodecontrol=document.getElementById('CellPhoneFieldAreaCode');
   if(CellPhoneFieldAreaCodecontrol!=null)
   {  
       CellPhoneFieldAreaCodecontrol.style.visibility='hidden';
   }
   
   var txtCitycontrol=document.getElementById('txtCity');
   if(txtCitycontrol!=null)
   {
     txtCitycontrol.style.visibility='hidden';
   }
   
   var lblCityEngcontrol=document.getElementById('lblCityEng');
   if(lblCityEngcontrol!=null)
   {
      lblCityEngcontrol.style.visibility='hidden';
   }
   
   var ddlCityFieldcontrol=document.getElementById('ddlCityField');
   if(ddlCityFieldcontrol!=null)
   {
      ddlCityFieldcontrol.style.visibility='hidden';
   }
   
   var lblCityTurkcontrol=document.getElementById('lblCityTurk');
   if(lblCityTurkcontrol!=null)
   {
      lblCityTurkcontrol.style.visibility='hidden';
   }
   
   var ddlCellPhoneFieldAreaCodecontrol=document.getElementById('ddlCellPhoneFieldAreaCode');
   if(ddlCellPhoneFieldAreaCodecontrol!=null)
   {
     ddlCellPhoneFieldAreaCodecontrol.style.visibility='hidden';
   }

   var CellphoneFieldPhoneNumbercontrol=document.getElementById('CellphoneFieldPhoneNumber');
   if(CellphoneFieldPhoneNumbercontrol!=null)
   {
      CellphoneFieldPhoneNumbercontrol.style.visibility='hidden';
   }
   
   var ddlCountryFieldcontrol=document.getElementById('ddlCountryField');
   if(ddlCountryFieldcontrol!=null)
   {
      ddlCountryFieldcontrol.style.visibility='hidden';
   }
   removeLock1();
}

function HideCodeFieldUpdateTextBox()
{
    var txtCode=document.getElementById('CellPhoneFieldAreaCodeU');
    if(txtCode!=null)
    {
        txtCode.style.visibility='hidden';
    }
    var ddlCode=document.getElementById('ddlCellPhoneFieldAreaCodeU');
    if(ddlCode!=null)
    {
        ddlCode.style.visibility='hidden';
    }
    var mynumber=document.getElementById('CellphoneFieldPhoneNumberU');
      if(mynumber!=null)
    {
        mynumber.style.visibility='hidden';
    }
    var mycity=document.getElementById('ddlCityFieldUpdate');
      if(mycity!=null)
    {
        mycity.style.visibility='hidden';
    }
   
   var txtCityUpdatecontrol=document.getElementById('txtCityUpdate');
   if(txtCityUpdatecontrol!=null)
   {
      txtCityUpdatecontrol.style.visibility='hidden';
   }
   
   var lblCityEngUcontrol=document.getElementById('lblCityEngU');
   if(lblCityEngUcontrol!=null) 
   {
       lblCityEngUcontrol.style.visibility='hidden';
   }
   
   var lblCityTurkUcontrol=document.getElementById('lblCityTurkU');
   if(lblCityTurkUcontrol!=null)
   {
      lblCityTurkUcontrol.style.visibility='hidden';
   }
   
   var ddlCountryFieldUcontrol=document.getElementById('ddlCountryFieldU');
   if(ddlCountryFieldUcontrol!=null)
   {
     ddlCountryFieldUcontrol.style.visibility='hidden';
   }
   
   
}

function DisplayCodeFieldUpdateTextBoxs()
{
   var CellphoneFieldPhoneNumberUcont=document.getElementById('CellphoneFieldPhoneNumberU');
         if(CellphoneFieldPhoneNumberUcont!=null) {CellphoneFieldPhoneNumberUcont.style.visibility='visible';} 
 
   var ddlCountryFieldUcont=document.getElementById('ddlCountryFieldU');
   if(ddlCountryFieldUcont!=null)
   {
     ddlCountryFieldUcont.style.visibility='visible';
     if(ddlCountryFieldUcont.value=='90')
     {
         var ddlCityFieldUpdatecont=document.getElementById('ddlCityFieldUpdate'); 
         if(ddlCityFieldUpdatecont!=null){ddlCityFieldUpdatecont.style.visibility='visible';}
   
   
         var ddlCellPhoneFieldAreaCodeUcont=document.getElementById('ddlCellPhoneFieldAreaCodeU');
        if(ddlCellPhoneFieldAreaCodeUcont!=null) {ddlCellPhoneFieldAreaCodeUcont.style.visibility='visible';}
         
          var lblCityTurkUcontrol=document.getElementById('lblCityTurkU');
          if(lblCityTurkUcontrol!=null)
          {
            lblCityTurkUcontrol.style.visibility='visible';
          }
          
           var CellPhoneFieldAreaCodeUcont=document.getElementById('CellPhoneFieldAreaCodeU');
        if(CellPhoneFieldAreaCodeUcont!=null) {CellPhoneFieldAreaCodeUcont.style.visibility='visible';}
         
     }
     else
     {
        var CellPhoneFieldAreaCodeUcont=document.getElementById('CellPhoneFieldAreaCodeU');
        if(CellPhoneFieldAreaCodeUcont!=null) {CellPhoneFieldAreaCodeUcont.style.visibility='visible';}
        
        var txtCityUpdatecont=document.getElementById('txtCityUpdate');
        if(txtCityUpdatecont!=null){txtCityUpdatecont.style.visibility='visible';}
        
        var lblCityEngUcont=document.getElementById('lblCityEngU');
        if(lblCityEngUcont!=null) {lblCityEngUcont.style.visibility='visible';}

        
     }
   }
 
}

function DisplayNewMemberTextBox()
{

  var CellphoneFieldPhoneNumbercont=document.getElementById('CellphoneFieldPhoneNumber');
  if(CellphoneFieldPhoneNumbercont!=null)
  {
      CellphoneFieldPhoneNumbercont.style.visibility='visible';
  }

   var ddlCountryFieldcont=document.getElementById('ddlCountryField');
   if(ddlCountryFieldcont!=null)
   {
       ddlCountryFieldcont.style.visibility='visible';
      if(ddlCountryFieldcont.value=='90')
      {
           var ddlCityFieldcont=document.getElementById('ddlCityField');
           if(ddlCityFieldcont!=null)
           {
            ddlCityFieldcont.style.visibility='visible';
           }
           
           var lblCityTurkcont=document.getElementById('lblCityTurk');
           if(lblCityTurkcont!=null)
           {
             lblCityTurkcont.style.visibility='visible';
           }
           
           var ddlCellPhoneFieldAreaCodecont=document.getElementById('ddlCellPhoneFieldAreaCode');
           if(ddlCellPhoneFieldAreaCodecont!=null)
           {
             ddlCellPhoneFieldAreaCodecont.style.visibility='visible';
           }
             var CellPhoneFieldAreaCodecont=document.getElementById('CellPhoneFieldAreaCode');
            if(CellPhoneFieldAreaCodecont!=null)
              {
                CellPhoneFieldAreaCodecont.style.visibility='visible';
               }
      }
      
      else
      
      {
          
          var txtCitycont=document.getElementById('txtCity');
          if(txtCitycont!=null)
          {
            txtCitycont.style.visibility='visible';
          }
       
          var lblCityEngcontrol=document.getElementById('lblCityEng');
         if(lblCityEngcontrol!=null)
         {
           lblCityEngcontrol.style.visibility='visible';
           
            var CellPhoneFieldAreaCodecont=document.getElementById('CellPhoneFieldAreaCode');
            if(CellPhoneFieldAreaCodecont!=null)
              {
                CellPhoneFieldAreaCodecont.style.visibility='visible';
               }
         }
      }
   }
    
   
  
}