/************************************************************************************************************
(C) www.dhtmlgoodies.com, September 2005
************************************************************************************************************/	

function scrollDiv_startScroll2(e)
{
	if(document.all)e = event;
	scrollbarTop2 = document.getElementById('scrolldiv_theScroll2').offsetTop;
	eventYPos2 = e.clientY;
	scrollActive2 = true;
}

function scrollDiv_stopScroll2()
{
	scrollActive2 = false;
	scrollbuttonActive2 = false;
	scrollMoveToActive2 = false;
}
function scrollDiv_scroll2(e)
{
	if(!scrollActive2)return;
	if(document.all)e = event;
	if(e.button!=1 && document.all) return;
	var topPos = scrollbarTop2 + e.clientY - eventYPos2; 
	if(topPos<0)topPos=0;
	if(topPos/1>visibleContentHeight2-(scrollHandleHeight2+4)/1)topPos = visibleContentHeight2-(scrollHandleHeight2+4);
	document.getElementById('scrolldiv_theScroll2').style.top = topPos + 'px';
	document.getElementById('scrolldiv_content2').style.top = 0 - Math.floor((contentHeight2) * ((topPos)/(visibleContentHeight2-scrollHandleHeight2)))+'px' 
}

/*
Click on the slider
Move the content to the this point
*/
function scrolldiv_scrollMoveToInit2(e)
{		
	if(document.all)e = event;
	scrollMoveToActive2 = true;
	scrollMoveToYPosition2 = e.clientY - document.getElementById('scrolldiv_scrollbar2').offsetTop;
	if(document.getElementById('scrolldiv_theScroll2').offsetTop/1 > scrollMoveToYPosition2) scrollbuttonDirection2 = scrollbuttonSpeed2*-2; else  scrollbuttonDirection2 = scrollbuttonSpeed2*2;
	scrolldiv_scrollMoveTo2();	
}

function scrolldiv_scrollMoveTo2()
{
	if(!scrollMoveToActive2 || scrollActive2)return;
	var topPos = document.getElementById('scrolldiv_theScroll2').style.top.replace('px','');
	topPos = topPos/1 + scrollbuttonDirection2;
	if(topPos<0){
		topPos=0;
		scrollMoveToActive2=false;
	}
	if(topPos/1>visibleContentHeight2-(scrollHandleHeight2+4)/1){
		topPos = visibleContentHeight2-(scrollHandleHeight2+4);	
		scrollMoveToActive2=false;
	}
	if(scrollbuttonDirection2<0 && topPos<scrollMoveToYPosition2-scrollHandleHeight2/2)return;	
	if(scrollbuttonDirection2>0 && topPos>scrollMoveToYPosition2-scrollHandleHeight2/2)return;			
	document.getElementById('scrolldiv_theScroll2').style.top = topPos + 'px';
	document.getElementById('scrolldiv_content2').style.top = 0 - Math.floor((contentHeight2) * ((topPos)/(visibleContentHeight2-scrollHandleHeight2)))+'px' 		
	scrollTime2=setTimeout('scrolldiv_scrollMoveTo2()',scrollTimer2);		
}

function cancelEvent2()
{
	return false;			
}

function scrolldiv_scrollButton2()
{
	if(this.id=='scrolldiv_scrollDown2')scrollbuttonDirection2 = scrollbuttonSpeed2; else scrollbuttonDirection2 = scrollbuttonSpeed2*-1;
	scrollbuttonActive2=true;
	scrolldiv_scrollButtonScroll2();
}
function scrolldiv_scrollButtonScroll2()
{
	if(!scrollbuttonActive2)return;
	var topPos = document.getElementById('scrolldiv_theScroll2').style.top.replace('px','');
	topPos = topPos/1 + scrollbuttonDirection2;
	if(topPos<0){
		topPos=0;
		scrollbuttonActive2=false;
	}
	if(topPos/1>visibleContentHeight2-(scrollHandleHeight2+4)/1){
		topPos = visibleContentHeight2-(scrollHandleHeight2+4);	
		scrollbuttonActive2=false;
	}	
	document.getElementById('scrolldiv_theScroll2').style.top = topPos + 'px';
	document.getElementById('scrolldiv_content2').style.top = 0 - Math.floor((contentHeight2) * ((topPos)/(visibleContentHeight2-scrollHandleHeight2)))+'px' 			
	scrollTime22=setTimeout('scrolldiv_scrollButtonScroll2()',scrollTimer2);
}

function scrolldiv_scrollButtonStop2()
{
	scrollbuttonActive2 = false;
}

function scrolldiv_initScroll2()
{
	visibleContentHeight2 = document.getElementById('scrolldiv_scrollbar2').offsetHeight ;
	contentHeight2 = document.getElementById('scrolldiv_content2').offsetHeight - visibleContentHeight2;		
	if (contentHeight2 <= 0) {
		scrollObj = document.getElementById('scrolldiv_slider2');
		scrollObj.style.display = "none";
		return;
	}
	scrollHandleObj2 = document.getElementById('scrolldiv_theScroll2');
	scrollHandleHeight2 = scrollHandleObj2.offsetHeight;
	scrollbarTop2 = document.getElementById('scrolldiv_scrollbar2').offsetTop;		
	document.getElementById('scrolldiv_theScroll2').onmousedown = scrollDiv_startScroll2;
	//document.body.onmousemove = initScrollDiv_scroll;
	document.getElementById('scrolldiv_scrollbar2').onselectstart = cancelEvent2;
	document.getElementById('scrolldiv_theScroll2').onmouseup = scrollDiv_stopScroll2;
	//if(document.all)document.body.onmouseup = scrollDiv_stopScroll2; else document.documentElement.onmouseup = scrollDiv_stopScroll2;
	document.getElementById('scrolldiv_scrollDown2').onmousedown = scrolldiv_scrollButton2;
	document.getElementById('scrolldiv_scrollUp2').onmousedown = scrolldiv_scrollButton2;
	document.getElementById('scrolldiv_scrollDown2').onmouseup = scrolldiv_scrollButtonStop2;
	document.getElementById('scrolldiv_scrollUp2').onmouseup = scrolldiv_scrollButtonStop2;
	document.getElementById('scrolldiv_scrollUp2').onselectstart = cancelEvent2;
	document.getElementById('scrolldiv_scrollDown2').onselectstart = cancelEvent2;
	document.getElementById('scrolldiv_scrollbar2').onmousedown = scrolldiv_scrollMoveToInit2;
}
/*
Change from the default color
*/	
function scrolldiv_setColor2(rgbColor)
{
	document.getElementById('scrolldiv_scrollbar2').style.borderColor = rgbColor;
	document.getElementById('scrolldiv_theScroll2').style.backgroundColor = rgbColor;
	document.getElementById('scrolldiv_scrollUp2').style.borderColor = rgbColor;
	document.getElementById('scrolldiv_scrollDown2').style.borderColor = rgbColor;
	document.getElementById('scrolldiv_scrollUp2').style.color = rgbColor;
	document.getElementById('scrolldiv_scrollDown2').style.color = rgbColor;
	document.getElementById('scrolldiv_parentContainer2').style.borderColor = rgbColor;
}
/*
Setting total width of scrolling div
*/
function scrolldiv_setWidth2(newWidth)
{
	document.getElementById('dhtmlgoodies_scrolldiv2').style.width = newWidth + 'px';
	document.getElementById('scrolldiv_parentContainer2').style.width = newWidth-30 + 'px';		
}

/*
Setting total height of scrolling div
*/
function scrolldiv_setHeight2(newHeight)
{
	document.getElementById('dhtmlgoodies_scrolldiv2').style.height = newHeight + 'px';
	document.getElementById('scrolldiv_parentContainer2').style.height = newHeight + 'px';
	document.getElementById('scrolldiv_slider2').style.height = newHeight + 'px';
	document.getElementById('scrolldiv_scrollbar2').style.height = newHeight-40 + 'px';		
}
/*
Setting new background color to the slider 
*/
function setSliderBgColor2(rgbColor)
{
	document.getElementById('scrolldiv_scrollbar2').style.backgroundColor = rgbColor;
	document.getElementById('scrolldiv_scrollUp2').style.backgroundColor = rgbColor;
	document.getElementById('scrolldiv_scrollDown2').style.backgroundColor = rgbColor;
}
/*
Setting new content background color
*/
function setContentBgColor2(rgbColor)
{
	document.getElementById('scrolldiv_parentContainer2').style.backgroundColor = rgbColor;
}

/*
Setting scroll button speed
*/
function setScrollButtonSpeed2(newScrollButtonSpeed)
{
	scrollbuttonSpeed2 = newScrollButtonSpeed;
}
/*
Setting interval of the scroll
*/
function setScrollTimer2(newInterval)
{
	scrollTimer2 = newInterval;
}

function voteScrollerInit2()
{
	scrolldiv_setColor2('#e28c05');	// Setting border color of the scrolling content
	//setSliderBgColor2('#E2EBED');	// Setting color of the slider div
	//setContentBgColor2('#FFFFFF');	// Setting color of the scrolling content
	setScrollButtonSpeed2(5);	// Setting speed of scrolling when someone clicks on the arrow or the slider
	setScrollTimer2(5);	// speed of 1 and timer of 5 is the same as speed of 2 and timer on 10 - what's the difference? 1 and 5 will make the scroll move a little smoother.
	scrolldiv_setWidth2(205);	// Setting total width of scrolling div
	scrolldiv_setHeight2(390);	// Setting total height of scrolling div
	scrolldiv_initScroll2();	// Initialize javascript functions
}