﻿// JScript File
        var targettop;
        var scrolling=false;
        function SetPosotion(divid,first)
        {
        
            var divwidth=removeunit(document.getElementById(divid).style.width);
            
           
            var left=__getBrowserRegionSize().width-divwidth;
            var top=__getScrollPosition().y;
           document.getElementById(divid).style.position="absolute";
           if(first!=null){
            document.getElementById(divid).style.left=left+'px';
            document.getElementById(divid).style.top=top+'px';
            document.getElementById(divid).style.display='block';
            
            }
            
            window.onresize=function() { 
                var sdivwidth=removeunit(document.getElementById(divid).style.width);
                var sleft=__getBrowserRegionSize().width-sdivwidth;
                var stop=__getScrollPosition().y;
                document.getElementById(divid).style.position="absolute";
                document.getElementById(divid).style.left=sleft+'px';
                document.getElementById(divid).style.top=stop+'px';
           
            }
            
            
            CreateAnimation(divid,left,top,removeunit(document.getElementById(divid).style.left),removeunit(document.getElementById(divid).style.top),20);      
        }
        function CreateAnimation(id,tleft,ttop,oleft,otop,step)
        {
            targettop=ttop;
            var top=ttop-otop;
           
            var inc=top/step;
            inc=Math.ceil(inc);
            animate(id,inc,step);
        }
        function animate(id,inc,step)
        {
            if(step!=0)
            {
                document.getElementById(id).style.top=removeunit(document.getElementById(id).style.top)+inc+'px';
                step=step-1;
                
                if(scrolling==true){
                setTimeout("animate('"+id+"',"+inc+","+step+");",1);
                }
                else
                { setTimeout("SetPosotion('"+id+"')",1);  
                }
            }else{
            setTimeout("SetPosotion('"+id+"')",1); 
            }
        }
        function removeunit(id)
        {
            
            return parseFloat(id.replace("px","").replace("%",""));
        }
    	function __getBrowserRegionSize()
	    {
    	    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; 
		    } 
		    if(navigator.userAgent.indexOf('MSIE')>=0)
                bodyWidth=bodyWidth-15;
            else
                bodyWidth=bodyWidth-31;
            bodyHeight=bodyHeight;
        
		    return {width:bodyWidth,height:bodyHeight};		
    		
	    }
	    function __getScrollPosition()
	    {
	       var nav4=window.event?true:false;
//           if (nav4) {
                     x1 =  document.documentElement.scrollLeft + document.body.scrollLeft;
                     y1 = document.documentElement.scrollTop + document.body.scrollTop;
//                }
//            else {
//                     x1 =window.scrollX;
//                     y1 = window.scrollY;
//                }
            
            return {x:x1,y:y1};
                
	    }
