// JavaScript Document


var How2go={};
How2go.Move=
{
	$:function(id)
	{
		if (null==id || id=='')
		{
			return null;	
		}
		else
		{
			return document.getElementById(id);	
		}
	}
	,IE:(navigator.userAgent.toLowerCase().indexOf('ie')>0)
	,FF:(navigator.userAgent.toLowerCase().indexOf('firefox')>0)
	,
    EventX:0
    ,
    EventY:0
   // ,
   // TempId:'${0}$'
    ,
	Open:function(e)
	{
		//window.open(url,'_blank');
		e=(e||event);  
                e.cancelBubble =true;    	
	},
    Dragsd:function(element,id)
    {
    
//    if(o.releaseCapture)o.releaseCapture(); 
//			else if(window.captureEvents) 
//			window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 

        //onmousedown="How2go.Move.Click(event,this,'abcd');"
       // var c=How2go.$(control);
        var p=this.$(id);
        //if ( null!=p)
        {
        if (this.IE)
        {
        //var temp=this.TempId.replace('{0}',control);
          //c.innerHTML +="<div unselectable=\"off\" id=\""+temp+"\" contentEditable style=\"position:absolute;width:100%;height:100%;cursor:move;margin-left:-1px;left:0px;top:0px;\"></div>";
        // How2go.$(temp).onkeydown=function()
				//{ 
					//	event.returnValue   =   false; 
			//	};
         element.onmousedown=function()
         {
            element.setCapture();
            //releaseCapture
            //c.ondragstart = "return false;";
		//c.onselectstart = "return false;"; 
		//c.onselect = "document.selection.empty();"; 
		//if(event.setCapture)event.setCapture();
		//else if(window.captureEvents);
		//window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 
		
            How2go.Move.Click(event,element,id);
            
         };
		}
		else
		{
         c.onmousedown=function(event)
         {
            How2go.Move.Click(event,element,id);
            
         };
         }
        }
    }
    ,
    Drag:function(e,element,id)
    {
        var obj=this.$(id);
            if (null!=obj)
            {
                e=(e||event);  
                e.cancelBubble =true;        
		    this.EventX=((e.x || parseInt(e.pageX)));
		    this.EventY=((e.y || parseInt(e.pageY)));	
		                                                         
                var parentNode=this.$('parentDIV');//document.aspnetForm;
                var height=parseInt(parentNode.offsetHeight);
                var width=parseInt(parentNode.offsetWidth);
                 
                
                    //window.getSelection && window.getSelection().removeAllRanges();
					if (How2go.Move.FF){window.getSelection().removeAllRanges();}
					if (!How2go.Move.FF && ! How2go.Move.IE){e.preventDefault();}	
                        element.setAttribute("unselectable","on"); 
                    if (How2go.Move.IE){element.setCapture();
                    }
                    else
                    {
                        element.style.MozUserSelect='none';
                    };
                       
                       
                       //contentEditable
                       document.onmousemove=function(ex)
					    {
		
							if (null==e){ex=event;}
							if(!How2go.Move.IE){e=ex;}
							var eventX=((e.x || parseInt(e.pageX)));
							var eventY=((e.y || parseInt(e.pageY)));							
							var dx=eventX-How2go.Move.EventX;
							var dy=eventY-How2go.Move.EventY;
							dx=(dx || 0);
							dy=(dy || 0);
							obj.style.left=parseInt(parseInt(obj.style.left)+parseInt(dx))+'px';
							obj.style.top=parseInt(parseInt(obj.style.top)+parseInt(dy))+'px';
							
							How2go.Move.EventX=((e.x || parseInt(e.pageX)));
		                    How2go.Move.EventY=((e.y || parseInt(e.pageY)));
						};
						document.onmouseup=function()
						{
						    document.onmousemove=document.onmouseup=null;
						    
						    if (How2go.Move.IE)
						    {
						         element.releaseCapture();
                                    //setCapture
						    }
						};
            }
      
    }
};
