
 var body_width =120;
var body_left  =-100;
var body_max_top   =500
var body_min_top   =0
function drag(o,s)
{  
    if (typeof o == "string") o = parent.window.frames['qqshow'].document.getElementById(o);  
    o.orig_index = o.style.zIndex;
    
    o.width = o.style.width;
    o.height = o.style.height;
    o.module = o.id;
    o.ismenu = false;
    if(o.module =="menu")
    {
       o.ismenu = true;
    }
    
    o.onmouseover = function()
    {
       //alert(this.style.width);
      // if(o.ismenu)
       //{
          this.style.border = "1px #000000 dashed";
      //}
    }
    
    o.onmouseout = function()
    {
       this.style.border = ""
    }
    
     o.onmouseleave=function()
     {
       setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
     }
    var tempEle;     
    o.onmousedown = function(a)  
    {  
        this.style.cursor = "move";  
        this.style.zIndex = 10000;  
        var d= parent.window.frames['qqshow'].document;  
        if(!a)a=window.event; 
       var x = getX(a) - ConvertToInt(o.style.left);
       var y = getY(a) - ConvertToInt(o.style.top);

        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
                  
        if(o.setCapture)  
            o.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
     
        
        d.onmousemove = function(a)  
        {  
           if(!a)a=window.event;
           var tempLeft =getX(a) - x;
           var tempTop  =getY(a) - y;
          // var width = ConvertToInt(o.width);
           var left = tempLeft;
         //  document.getElementById("div00").innerHTML = "width:"+width+"  tempLeft:"+tempLeft+"  left:"+left+" x:"+getX(a)+" width:"+x+"<br>  ";

//            //710 738   716 744 718 
          //X轴
           if(tempLeft<body_width && tempLeft>5)
                {
                 o.style.left = tempLeft;
                }
            else  if(tempLeft>body_width)
                {
                 o.style.left =body_width-o.width;
                }
            else  if(tempLeft<=body_left)
               {
                  o.style.left = tempLeft; 
                }
          //Y轴
           if(tempTop> body_max_top)
               {
                  o.style.top =body_max_top-o.height;
               }
           else  if(tempTop<body_min_top)
               {
                
                 o.style.top =body_min_top;
               }   
             else if(tempTop<body_max_top && tempTop>body_min_top)
             {
              o.style.top =tempTop;
             }
             
        }  

        d.onmouseup = function()  
        {  
         
            if(o.releaseCapture)  
                o.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
            o.style.cursor = "normal";  
            o.style.zIndex = o.orig_index; 

            var left = ConvertToInt(o.style.left);
            var top = ConvertToInt(o.style.top);
         //   fn_Send_Server(o.module,left,top);
              setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
        }  
        d.onmouseleave=function()
        {
         setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
        }
       
   }
   return o.id;
}


function Mdrag(o,s)
{  
    if (typeof o == "string") o = document.getElementById(o);  
    o.orig_index = o.style.zIndex;
    
    o.width = o.style.width;
    o.height = o.style.height;
    o.module = o.id;
    o.ismenu = false;
    if(o.module =="menu")
    {
       o.ismenu = true;
    }
    
    o.onmouseover = function()
    {
       //alert(this.style.width);
      // if(o.ismenu)
       //{
          this.style.border = "1px #000000 dashed";
      //}
    }
    
    o.onmouseout = function()
    {
       this.style.border = ""
    }
    
     o.onmouseleave=function()
     {
       setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
     }
    var tempEle;     
    o.onmousedown = function(a)  
    {  
        this.style.cursor = "move";  
        this.style.zIndex = 10000;  
        var d= parent.window.frames['qqshow'].document;  
        if(!a)a=window.event; 
       var x = getX(a) - ConvertToInt(o.style.left);
       var y = getY(a) - ConvertToInt(o.style.top);

        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
                  
        if(o.setCapture)  
            o.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
     
        
        d.onmousemove = function(a)  
        {  
           if(!a)a=window.event;
           var tempLeft =getX(a) - x;
           var tempTop  =getY(a) - y;
          // var width = ConvertToInt(o.width);
           var left = tempLeft;
         //  document.getElementById("div00").innerHTML = "width:"+width+"  tempLeft:"+tempLeft+"  left:"+left+" x:"+getX(a)+" width:"+x+"<br>  ";

//            //710 738   716 744 718 
          //X轴
           if(tempLeft<body_width && tempLeft>5)
                {
                 o.style.left = tempLeft;
                }
            else  if(tempLeft>body_width)
                {
                 o.style.left =body_width-o.width;
                }
            else  if(tempLeft<=body_left)
               {
                  o.style.left = tempLeft; 
                }
          //Y轴
           if(tempTop> body_max_top)
               {
                  o.style.top =body_max_top-o.height;
               }
           else  if(tempTop<body_min_top)
               {
                
                 o.style.top =body_min_top;
               }   
             else if(tempTop<body_max_top && tempTop>body_min_top)
             {
              o.style.top =tempTop;
             }
             
        }  

        d.onmouseup = function()  
        {  
         
            if(o.releaseCapture)  
                o.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
            o.style.cursor = "normal";  
            o.style.zIndex = o.orig_index; 

            var left = ConvertToInt(o.style.left);
            var top = ConvertToInt(o.style.top);
         //   fn_Send_Server(o.module,left,top);
              setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
        }  
        d.onmouseleave=function()
        {
         setCookie1("temp_"+o.id.toString(),ConvertToInt1(o.style.left)+"|"+ConvertToInt1(o.style.top));
        }
       
   }
   return o.id;
}




//获得COOKIE
 
  function getCookie1(name) 
    {

      var search;
      search = name + "="
      offset = document.cookie.indexOf(search) 
      if (offset != -1) {
        offset += search.length ;
        end = document.cookie.indexOf(";", offset) ;
        if (end == -1)
          end = document.cookie.length;
        return unescape(document.cookie.substring(offset, end));
      }
      else
      {
        return "";
       }
    }
function ConvertToInt1(strPx)
{
   return parseInt(strPx.replace("px",""));
}
 //设置COOKIE    
     
   function setCookie1(name, value) 
   {

      //document.cookie = name + "=" + escape(value) + "; path=/; domain=qqshow.qq.com";
      document.cookie = name + "=" + value + ";";
    }
  function getX(e)
  {
		if (window.navigator.userAgent.indexOf("MSIE")>=1)
		{
		  return e.x
		}else
		{
			if (window.navigator.userAgent.indexOf("Firefox")>=1)
			{
			return e.clientX;
			}
			else
			{
			alert('对不起,该功能支持IE和Firefox');
			}
		}
}

function getY(e)
{
   	if (window.navigator.userAgent.indexOf("MSIE")>=1)
	{
		return e.y
	}else
	{
		if (window.navigator.userAgent.indexOf("Firefox")>=1)
		{
		  return e.clientY;
		}
		else
		{
		  alert('对不起,该功能支持IE和Firefox');
		}
	}
}


 createElement = function(NodeName, Property, Style, NodeText) 
 { 
    var e = document.createElement(NodeName); 
    if (Property) 
    { 
        for (var p in Property) 
        { 
            if (p == 'class') e.className = Property[p]; 
            else if (p== 'id') e.id = Property[p]; 
            else e.setAttribute(p, Property[p]); 
        } 
    } 
    if (Style) 
    { 
		for (var s in Style) 
		{
		   e.style[s] = Style[s]; 
		}
    }

    e.style.position="absolute";
    
    if (NodeText) 
    {        
      e.innerHTML = NodeText; 
    }  

    return e; 
} 
function ConvertToInt(strPx)
{
   return parseInt(strPx.replace("px",""));
}



function ConverToPix(iPos)
{
   return iPos+"px";
}
