/*******************************************************************************
* Project: StuffSpace 2.0                                                      *
* File: stuff.js (Javascript File for stuffspace)                              *
* Author: Cody Garvin                                                          *
*                                                                              *
********************************************************************************
* Date: 06/27/08                                                               *
* Version: 0.1                                                                 *
* History:                                                                     *
*  06/27/08 - Initial script created.                                          *
*                                                                              *		
*******************************************************************************/
/* Scrolling Functions */

var scrollLeftTO;
var scrollRightTO
function goScrollLeft()
{
	scrollLeftTO = setTimeout('doScroll("left")',500);
}
function goScrollRight()
{
	scrollRightTO = setTimeout('doScroll("right")',500);
}


function stopScrollLeft()
{
	if(scrollLeftTO)
	{
		clearTimeout(scrollLeftTO);
	}
}	

function stopScrollRight()
{
	if(scrollRightTO)
	{
		clearTimeout(scrollRightTO);
	}
}	

var pointerLeft  = 0;
var pointerRight = 0;
var opacityLeft  = 0;
var opacityRight = 0;
	
function doScroll(type)
{
	var EvString = '';
	if(type == "left") // It's the left
	{
		var thisPointer = pointerLeft;
		var choice      = Review;
		var chosenTitle = "choosenOneLeft";		
	}
	else // It's the right
	{
		var thisPointer = pointerRight;		
		var choice      = Blog;		
		var chosenTitle = "choosenOneRight";
	}
	var choosenOne = '';
	for(count=1; count <= 4; count++)
	{
		if(count == 4)
		{
			choosenOne = 'id="'+chosenTitle+'" style="opacity:0;border-bottom: 1px solid #cccccc; margin-top: 5px; margin-left: 15px;"';    
		}
		else
		{
			choosenOne = '';
		}
		
		if(type == "left")
		{
			//  IMAGE||ITEMID||TITLE||RATING||REVIEW||UID||USERNAME||PERCENT||NUMCOMMENTS
			EvString = "<table width='445' border='0' cellpadding='0' cellspacing='0' "+choosenOne+" style='border-bottom: 1px solid #cccccc; margin-top: 5px; margin-left: 15px;'><tr><td height='50' width='50' valign='top' align='left'><img src='"+choice[thisPointer].toString().split('||')[0]+"' border='0' /></td><td valign='top'><table width='390' border='0' cellpadding='3' cellspacing='0'><tr><td colspan='3' valign='top' style='font-size: 13px;' align='left'><a href='items/index.php?itemid="+choice[thisPointer].toString().split('||')[1]+"'>"+choice[thisPointer].toString().split('||')[2]+"</a></td></tr><tr><td colspan='3' align='left'>"+choice[thisPointer].toString().split('||')[3]+"</td></tr><tr><td colspan='3' style='font-size: 11px;' align='left'>\""+choice[thisPointer].toString().split('||')[4]+" <a href='items/index.php?itemid="+choice[thisPointer].toString().split('||')[1]+"'>(read more)</a>\"</td></tr><tr><td style='font-size: 11px;' width='34%' align='left'>By <a href='user/index.php?id="+choice[thisPointer].toString().split('||')[5]+"'>"+choice[thisPointer].toString().split('||')[6]+"</a></td><td style='font-size: 11px;' width='33%' align='center'>"+choice[thisPointer].toString().split('||')[7]+"</td><td style='font-size: 11px;' width='33%' align='center'>"+choice[thisPointer].toString().split('||')[8]+" Comments</td></tr></table></td></tr></table>"+EvString;
		}
		else
		{
			// URL||TITLE||USERNAME||DATEADDED||BLOG||USERID||NUMBEROFCOMMENTS		
			EvString = "<table width='445' border='0' cellpadding='3' cellspacing='0' "+choosenOne+" style='border-bottom: 1px solid #cccccc; margin-top: 5px; margin-left: 15px;'><tr><td colspan='2' align='left'><div style='font-size: 13px;'><a href=\""+choice[thisPointer].toString().split('||')[0]+"\">"+choice[thisPointer].toString().split('||')[1]+"</a></div></td></tr><tr><td colspan='2' align='left'><div style=' margin-bottom: 5px;'><font class=\"orange\">"+choice[thisPointer].toString().split('||')[2]+" blogged on "+choice[thisPointer].toString().split('||')[3]+":</font> \""+choice[thisPointer].toString().split('||')[4]+"\"</div></td></tr><tr><td style='font-size: 11px;' width='65%' align='left'>By <a href='user/index.php?id="+choice[thisPointer].toString().split('||')[5]+"'>"+choice[thisPointer].toString().split('||')[2]+"</a></td><td style='font-size: 11px;' width='35%' align='center' align='right'>"+choice[thisPointer].toString().split('||')[6]+" Comments</td></tr></table>"+ EvString;
		}
		thisPointer++;
		
		if(thisPointer > (choice.length - 1))
		{
			thisPointer = 0;
		}
	}
	
	if(type == "left")
	{
		pointerLeft++;
		if(pointerLeft > (choice.length - 1))
		{
			pointerLeft = 0;
		}
		
		document.getElementById('leftScroller').innerHTML = EvString;
		opacityLeft = 0;
		appearLeft();
		scrollLeftTO = setTimeout("doScroll('left')",6000);		
	}
	else
	{
		pointerRight++;
		if(pointerRight > (choice.length - 1))
		{
			pointerRight = 0;
		}	
		
		document.getElementById('rightScroller').innerHTML = EvString;
		opacityRight = 0;
		appearRight();
		scrollRightTO = setTimeout("doScroll('right')",6000);		
	}
	

}	
	
function appearLeft()
{
	if(document.all)
	{
		document.getElementById('choosenOneLeft').style.filter = 'alpha(opacity=' + opacityLeft + ')';
	}
	else
	{
		document.getElementById('choosenOneLeft').style.opacity = opacityLeft/100;
	}
	
	opacityLeft = opacityLeft + 20;
	if(opacityLeft <= 100)
	{
		setTimeout("appearLeft()", 150);
	}
}	

function appearRight()
{
	if(document.all)
	{
		document.getElementById('choosenOneRight').style.filter = 'alpha(opacity=' + opacityRight + ')';
	}
	else
	{
		document.getElementById('choosenOneRight').style.opacity = opacityRight/100;
	}
	
	opacityRight = opacityRight + 20;
	if(opacityRight <= 100)
	{
		setTimeout("appearRight()",150);
	}
}	


////////////////////////////////////////////////////////////////////////////////////////////////////

	var main = new Array();
	main[0] = "The one place to keep track of all the stuff you own, review it, see others who own it.";
	main[1] = "Keep track of and review ALL your stuff. Not just your books. Not just your movies. ALL of it, in one place.. StuffSpace (we don't sell anything, so we don't care where you bought it from).";
	main[2] = "A user-editable product database for ALL stuff. Something missing? Simply add it yourself! A spec wrong? Update it instantly!";
	main[3] = "Show off your collections and compare them to others.. who has the coolest stuff?";
	main[4] = "Group related items into Collections to show off (home theater systems anyone?)..then add it to a Collection Group to check out everyone else's and discuss who has the best on the Group's forum!";
	main[5] = "A trusted resource.. rate other people's reviews, get notified when someone you trust writes a review, blogs, and more. We don't sell anything, so we only care about unbiased, informative reviews.. positive OR negative.";
	main[6] = "Review the reviewers.. \"It sux\" isn't a review, it's an admission of stupidity. Every review is reviewable by others on a 1-10 scale. How good are YOUR reviews?";
	main[7] = "Product Discovery.. Love a cd? Check out who else does too, and see the other stuff they love and discover new stuff you might love too that you never knew about!";
	main[8] = "Don't get product recommendations from a machine.. check out who else loves the stuff you do and see what they have that you don't. Don't know if you'll like it? Ask them about it and find new stuff to love!";
	
var scrollMainTO;
function goScrollMain()
{
	scrollMainTO = setTimeout('doScrollMain()',500);
}

function stopScrollMain()
{
	if(scrollMainTO)
	{
		clearTimeout(scrollMainTO);
	}
}	
var pointerMain = 0;
var opacityMain = 0;
	
function doScrollMain()
{
	var EvString = '';
	var thisPointer = pointerMain;
	var mainOne = '';
	
	mainOne = 'id="mainOne" style="opacity:0; text-align: center; color: #ff9001; font-size: 16px; line-height: 24px; margin: auto;"';    

	EvString = "<div "+mainOne+">"+main[pointerMain].toString()+"</div><div width='100%' align='right'>Join here</div>";
			
	pointerMain++;
	if(pointerMain > (main.length - 1))
	{
		pointerMain = 0;
	}
	
	document.getElementById('adContent').innerHTML = EvString;
	opacityMain = 0;
	appearMain();
	scrollMainTO = setTimeout("doScrollMain()",9000);
}	
	
function appearMain()
{
	if(document.all)
	{
		document.getElementById('mainOne').style.filter = 'alpha(opacity=' + opacityMain + ')';
	}
	else
	{
		document.getElementById('mainOne').style.opacity = opacityMain/100;
	}
	
	opacityMain = opacityMain + 20;
	if(opacityMain <= 100)
	{
		setTimeout("appearMain()",100);
	}
}	
