var theid ,children, atimer, godown, thestart, lowestpos, gap, rollingPos, counter;
godown=0;
counter=0;
i=0;
lowestpos = 0;
gap=2;
rollingPos = 0;

function slideDivs(container,requestQuery){ 
//ignore rest, as no longer sliding buttons in
    if (requestQuery != "")
    	{
		var community, community2;
		community = getQueryString("community", requestQuery);
		community2 = getQueryString("community", parent.location.search);
    	if (community == community2) {showDivs(container);return;}
		}

	children = new Array();
	childrenWidth = new Array();
	theid=VT_getObjectByID(container);
	if(theid){
		thestart=theid.scrollWidth;
		for(var i=0; i<theid.childNodes.length; i++){		
			// Firefox puts in lots of #text nodes...skip these
			if(theid.childNodes[i].nodeName=='#text') continue;
			children[i]=theid.childNodes[i].id;
		}		
	}
		
	for(var i=0; i<children.length; i++){
		if(children[i] > ''){
			counter++;
			theid=VT_getObjectByID(children[i]);
			//childrenWidth[i] = parseInt(stripChars(theid.style.marginLeft,'px'));
			//if (lowestpos > childrenWidth[i]) {
				//godown=i;
				//lowestpos = childrenWidth[i];
			//}
			theid.style.marginLeft=thestart;
			var startpoint
			if(wbIE){startpoint=0;}else{startpoint=1;}
			if(i==startpoint){
				theid.VT_pos = ((thestart-gap)-theid.clientWidth);
				rollingPos = theid.VT_pos;
			}else{
				theid.VT_pos = ((rollingPos-gap)-theid.clientWidth);
				rollingPos = theid.VT_pos;
			}
		 	lowestpos = rollingPos;	
			theid.style.zIndex=children.length-i;
		}
	}	
	
	atimer = setInterval ( "move();",1 );
}

function showDivs(container){

	children = new Array();
	childrenWidth = new Array();
	theid=VT_getObjectByID(container);
	if(theid){
		thestart=theid.scrollWidth;
		for(var i=0; i<theid.childNodes.length; i++){		
			// Firefox puts in lots of #text nodes...skip these
			if(theid.childNodes[i].nodeName=='#text') continue;
			children[i]=theid.childNodes[i].id;
		}		
	}

	for(var i=0; i<children.length; i++){
		if(children[i] > ''){
			counter++;
			theid=VT_getObjectByID(children[i]);
			childrenWidth[i] = parseInt(stripChars(theid.style.marginLeft,'px'));
			//if (lowestpos > childrenWidth[i]) {
			//	godown=i;
			//	lowestpos = childrenWidth[i];
			//}
			//theid.style.marginLeft=thestart;
			var startpoint
			if(wbIE){startpoint=0;}else{startpoint=1;}
			if(i==startpoint){
				theid.VT_pos = ((thestart-gap)-theid.clientWidth);
				rollingPos = theid.VT_pos;
			}else{
				theid.VT_pos = ((rollingPos-gap)-theid.clientWidth);
				rollingPos = theid.VT_pos;
			}
		 	lowestpos = rollingPos;
			//theid.style.zIndex=children.length-i;
		}
	}
	counter=0;
	for(var i=children.length; i>=0; i--){
		if(children[i] > ''){
			
			theid=VT_getObjectByID(children[i]);
			//childrenWidth[i] = parseInt(stripChars(theid.style.marginLeft,'px'));
			//if (lowestpos > childrenWidth[i]) {
				//godown=i;
				//lowestpos = childrenWidth[i];
			//}
			//theid.style.marginLeft=thestart;
			if (counter==0){

				theid.style.marginLeft = lowestpos;
			}else{
				//theid.style.marginLeft = (parseInt(lowestpos) + (parseInt(gap))) + parseInt(theid.clientWidth);
				theid.style.marginLeft = (parseInt(lowestpos) + (parseInt(gap))) + parseInt(64);
				lowestpos = stripChars(theid.style.marginLeft,'px');
			}
			counter++;
			theid.style.visibility='visible';
		}
	}	

}

function move(){
	for(var i=0; i<children.length; i++){
		if(children[i] > ''){
			theid=VT_getObjectByID(children[i]);
			//var x = Math.cos(Math.PI*thestart/children.length) - 1;
			//var posX =  (-1 * (x) + (i+5));
			var posX = (i+1)*4;  //SPEED is the multiplier
			
			if(stripChars(theid.style.marginLeft,'px')>= theid.VT_pos){
				theid.style.marginLeft = stripChars(theid.style.marginLeft,'px')-posX;			
			}
			
			else{
				godown++;
				theid.style.marginLeft = theid.VT_pos;
				if ( (godown == counter) ){
					clearInterval ( atimer );
						
					break;
				}
			}
			if(parseInt(stripChars(theid.style.marginLeft,'px'))<(thestart-theid.clientWidth) && theid.style.visibility!='visible'){
				theid.style.visibility='visible';
			}		
		}
	}
}






function getQueryString(key, query)
{
	//query = parent.location.search;
	
	if (query.length > 1)
		{
		query = query.substring(1, query.length); 
		for(var i=0; i < query.split("&").length; i++)
			{
			subQuery = query.split("&")[i];
			subQueryKey = subQuery.split("=")[0];
			subQueryValue = subQuery.split("=")[1];
			if (subQueryKey.toLowerCase()==key.toLowerCase())
				{
				return subQueryValue;
				}
			}
		}
	else
		{
		return null;
		}
	return null;
}