var contentItemWidth = 137;
var inactiveWidth = 30;
var curLeftOffset = 0;
var expertiseTimer = null;
var scrolltextTimer = null;
var scrollertext;
var expertisetext;
var scroller;

function initScroller()
{
	scroller = document.getElementById("scroller");
	if (!scroller) return;
	scrollertext	= document.getElementById("scrollertext");
	expertisetext	= document.getElementById("expertisetext");

	imliveGreeting = scrollertext.innerHTML;
	scroller.onmousemove	= ScrollDiv;
	window.onresize = findPos;

	scrollerWidth		= scroller.offsetWidth;
	activeWidth		= scrollerWidth - 2 * inactiveWidth;
	contentItems		= scroller.getElementsByTagName('a').length;
	contentWidth		= contentItems * contentItemWidth;
	contentScrollQuotient	= ( contentWidth - scrollerWidth ) / activeWidth;

	findPos();

}

function findPos() {
	obj = scroller;
	if (obj.offsetParent) {
		curLeftOffset = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			curLeftOffset += obj.offsetLeft;
		}
	}
}

function ScrollDiv(event)
{
	var e = event || window.event;
	var PointerPosition = e.clientX - curLeftOffset;
	popupPosX = e.clientX;
	popupPosY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

	if ( PointerPosition < inactiveWidth )
	{
		PointerPosition = inactiveWidth;
	};
	if ( PointerPosition > scrollerWidth - inactiveWidth )
	{
		PointerPosition = scrollerWidth - inactiveWidth;
	};

	PointerPosition -= inactiveWidth;
	scroller.scrollLeft = PointerPosition * contentScrollQuotient;
}

function dTitle(nick,url,expertise) {

	if (expertiseTimer != null) {
		clearTimeout(expertiseTimer);
		clearTimeout(scrolltextTimer);
		expertiseTimer = null;
	}
	scrollertext.innerHTML = 'Jerk off and cum with lovely <a href="' + url + '" target="_blank">' + nick + '</a> right now!';
	expertisetext.innerHTML = 'Have a <font color="red"><strong>FREE</strong></font> video chat with<br /><strong>'+nick+'</strong><br /><br />' + expertise;
	expertisetext.style.visibility='visible';
	expertisetext.style.left=popupPosX + 5 + "px";
	expertisetext.style.top=popupPosY + 15 + "px";
}

function dTitleOut() {
	expertiseTimer = setTimeout("expertisetext.style.visibility='hidden';",250);
	scrolltextTimer = setTimeout("scrollertext.innerHTML = imliveGreeting;",4000);
}

function imlive_reposition() {
 var imlivediv = document.getElementById("slide_up");
 if (imlivediv) {
	imlivetop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	imlivetop += (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
	imlivetop -= (imlivediv.clientHeight + 2);
	imlivediv.style.top = imlivetop + "px";
 }
}

function GA_links () {
var F=document.links;
for (i = 0; i < F.length; i++) {
 urlStart=F[i].href.lastIndexOf("attachmentid=");
 if ( urlStart > 1 ) { 
	urlLen=F[i].href.length;
	urlString=F[i].href.substring(urlStart+13,urlLen);
	if ( urlString.indexOf("?") > -1) {
		urlString = urlString.substring(0,urlString.indexOf("?")); } 
	if ( urlString.indexOf("&") > -1) {
		urlString = urlString.substring(0,urlString.indexOf("&")); } 

	F[i].name=urlString;
        F[i].onclick = s0;
 }
}
}

function s0 () { 
	pageTracker._trackPageview('/attach/'+this.name);
} 
