
// showAll

var swapall_state = 'show';

function swapAll(count) {

	var showall_img = document.getElementById("showall_btn");
		
	if (swapall_state == 'show')
	{
		swapall_state = 'hide';
		showall_img.src = "images/hideall_btn.gif";
		location.href = location.href + '#initswap';

		for (var i=1;i<=count;i++) 
		{
			objToShow = "items_" + i;
			title = "category_" +i;
			var nScrollHeight = document.getElementById(objToShow).scrollHeight;
			sizeObjV(objToShow,nScrollHeight,"null");
			document.getElementById(title).className = "expand-selected"; 
			// setTimeout(' sizeObjV("items_1", document.getElementById("items_1").scrollHeight,"null");  document.getElementById(title).className = "expand-selected";  ', 2000);
		
		}	
	}
	else
	{
		swapall_state = 'show';
		showall_img.src = "images/showall_btn.gif";			
		location.href = location.href.substr(0, location.href.indexOf('#'));	
		for (var i=1;i<=count;i++) 
		{
			objToShow = "items_" + i;
			title = "category_" +i;
			sizeObjV(objToShow,1,"null");
			setTimeout('document.getElementById(title).className = "expand-normal";', i * 2000);
		}
	}
}


// expand functions
function showExpand(title,objToShow,expandGroup) {
	var nScrollHeight = document.getElementById(objToShow).scrollHeight;
	var nActualHeight = document.getElementById(objToShow).offsetHeight;
	var arrow = "arrow_" + title.split("_")[1];
	if (nActualHeight < nScrollHeight) {
		sizeObjV(objToShow,nScrollHeight,"null");
		document.getElementById(title).className = "expand-selected";
		//document.getElementById(arrow).src = arrow_up.src;
	}
	else {
		sizeObjV(objToShow,1,"null");
		document.getElementById(title).className = "expand-normal";
		//document.getElementById(arrow).src = arrow_down.src;
	}
}

function hoverExpand(title,hover) {
	if (document.getElementById(title).className != "expand-selected"){
		//var arrow = "arrow_" + title.split("_")[1];
		if (hover) { 
			document.getElementById(title).className = "expand-hover";
			//document.getElementById(arrow).src = arrow_hover.src;
		}
		else { 
			document.getElementById(title).className = "expand-normal";
			//document.getElementById(arrow).src = arrow_down.src;
		}
	}
}

function sizeObjV(objToShow,showSize,completeFunction) {
	//completeFunction should take format: null OR {complete:function() {setStatus('done fading element.',1500);}} 
	new Rico.Effect.Size(document.getElementById(objToShow),null,showSize,20,10,completeFunction);	
}

function sizeObjH(objToShow,showSize,completeFunction) {
	//completeFunction should take format: null OR {complete:function() {setStatus('done fading element.',1500);}} 
	new Rico.Effect.Size(document.getElementById(objToShow),showSize,null,20,10,completeFunction);	
}

function fadeObjV(objToFade,opacity,completeFunction) {
	new Rico.Effect.FadeTo(document.getElementById(objToFade),opacity,500,10,completeFunction);
}
