// slide effect for the price compare

// need to pass div name, initial size(max size), slide time? -- if it is open or closed do different things;

// function to get div initial height, set height to 0, etc.

var scrolling=false;

function startslide(divname, priceheight) {
	//document.getElementById('debug').innerHTML+=priceheight+'\n';
	document.getElementById(divname).style.height="1";
	scrollprice(divname, priceheight);
}

function getdivheight(divname) {
	return document.getElementById(divname).offsetHeight;
}

function scrollprice(divname, priceheight) {
	var curheight=getdivheight(divname);
	if(!scrolling) {
	//document.getElementById('debug').innerHTML+=curheight+'\n ini \n';
	if(curheight < 20) {
		scrollpriceDn(divname, true, priceheight);
	}
	else {
		scrollpriceUp(divname, true, priceheight);
	}
	//scrolltest(divname);
	}
}


function scrollpriceDn(divname, scrollstatus, priceheight) {
	if(scrollstatus) {
		scrolling=true;
		var curheight=getdivheight(divname);
		if (curheight < priceheight) {
			curheight+=5;
			//document.getElementById('debug').innerHTML+=curheight+' down ';
			document.getElementById(divname).style.height=curheight+"px";
			if(curheight > priceheight) {
				//document.getElementById('debug').innerHTML+='end';
				curheight=priceheight;
				document.getElementById(divname).style.height=eval(priceheight)+"px";
				scrollstatus=false;
				scrolling=false;
			}
			//scrollstatus=false;
		}
		else {
			scrollstatus=false;
			scrolling=false;
		}
		setTimeout('scrollpriceDn("'+divname+'",'+scrollstatus+', '+priceheight+')',30);
		//setTimeout('alert("blarg")', 25);
		//document.getElementById('debugme').value+="\n"+topPos;
		//document.getElementById('debugme').value+=" - "+document.getElementById(divname).style.top;
	}
}

function scrollpriceUp(divname, scrollstatus, priceheight) {
	if(scrollstatus) {
		scrolling=true;
		var curheight=getdivheight(divname);
		if(curheight > 1) {
				curheight-=5;
			//document.getElementById('debug').innerHTML+=curheight+' up ';
			document.getElementById(divname).style.height= curheight;
			if (curheight < 5) {
				curheight=1;
				document.getElementById(divname).style.height=curheight+"px";
				scrollstatus=false;
				scrolling=false;
			}
		}
		else {
			scrollstatus=false;
			scrolling=false;
		}
		setTimeout('scrollpriceUp("'+divname+'",'+scrollstatus+', '+priceheight+')',30);
		//document.getElementById('debugme').value+="\n"+topPos;
		//document.getElementById('debugme').value+=" - "+document.getElementById(divname).style.top;
	}
}