var scrollBarHeight = 265;
var contentPaneHeight = 265;
var diffX, diffY, theElement, eventVar;
var contentHeight;
var contentMargin = 0;
var scrollFaceHeight = 32;

function scrollDrag(event)
{
    eventVar = event;
    theElement = document.getElementById('scrollFace');//event.currentTarget;
    var posX = parseInt(theElement.style.left);
    var posY = parseInt(theElement.style.top);
    
    diffX =eventVar.clientX - posX;
    diffY =eventVar.clientY - posY;
    
    document.onmousemove = mover;
    document.onmouseup = dropper;
    
    try{event.stopPropagation();}
    catch(e){}
    try {event.preventDefault();}
    catch(e){}
    
}

function mover(event)
{
    //theElement.style.left = (event.clientX - diffX) + "px";
    
    try{event.clientY}
    catch(e){event = eventVar}
    
    if (event.clientY-diffY <= 0)  //top of scroll
        {
            theElement.style.top = "0px";
            document.getElementById('scroll_content').style.top = "0px";
        }
        else if(event.clientY-diffY >= scrollBarHeight-scrollFaceHeight) //bottom of scroll
            {
                theElement.style.top = scrollBarHeight - scrollFaceHeight + "px";
                document.getElementById('scroll_content').style.top = -(contentHeight-contentPaneHeight)+"px";
            }
            else  //somewhere in mid of scroll
                {
                    theElement.style.top = (event.clientY - diffY) + "px";
                    document.getElementById('scroll_content').style.top = -(contentHeight-contentPaneHeight) * ((event.clientY - diffY) / (scrollBarHeight-scrollFaceHeight)) +"px";
                }
                //document.getElementById('debug').innerHTML = "TOP: "+document.getElementById('scroll_content').style.top+" --- diffX: " +diffX+ ", DiffY: "+diffY;
                try{eventVar.stopPropagation();}
                catch(e){}
            }
            
            function dropper(event) 
            {	
                document.onmousemove = null;
                document.onmouseup = null;
                try{eventVar.stopPropagation();}
                catch(e){}
            }
            
            function getHeight()
            {
                if (document.getElementById('scroll_content')!= null)
                    {
                        contentHeight = document.getElementById('scroll_content').offsetHeight;
                        contentHeight += contentMargin*2;
                        if (contentHeight > contentPaneHeight)
                            document.getElementById('scrollBar').style.visibility = "visible";
                        else
                            document.getElementById('scrollBar').style.visibility = "hidden";
                    }
                }
                
                
function check_scroll_content(){
    return $('scroll_content').style.top;
}
function check_scrollFace(){
    return $('scrollFace').style.top;
}
function sharethis(){
var NewScript=document.createElement('script')
NewScript.src="http://w.sharethis.com/button/sharethis.js#publisher=a285c094-78df-4351-9075-df342b19edab&amp;type=website&amp;embeds=true"  
$('share').appendChild(NewScript); 
}
