

function wipeShow2(nodeId, callback) {
	var node = document.getElementById(nodeId);
	
	// Calculate the expanded height
	//var overflow = dojo.html.getStyle(node, "overflow");
	node.style.overflow = "hidden";
	node.style.height = "0px";
	node.style.display = 'block';

	var height = node.scrollHeight;
	
	sinWipe(nodeId, 0, height, getDx(height), 0, function() { if(callback) { callback(node); }});
}

wipeHide2 = function(nodeId, callback) {
	var node = document.getElementById(nodeId);
	var height = node.offsetHeight;
	//var overflow = dojo.html.getStyle(node, "overflow");
	node.style.overflow = "hidden";
	
	sinWipe(nodeId, height, 0, getDx(height), 0, callback);
}

getDx = function(height) {
	var steps = Math.round(height / 45); // duration / 5.0;
	steps = (steps > 15 ? 15 : (steps < 7 ? 7 : steps));
	var dx = Math.PI / steps;
	return dx;
}

pi = Math.PI;
function sinWipe(nodeId, startHeight, endHeight, dx, xVal, cb)
{
	var node = document.getElementById(nodeId);
	xVal += dx;
	if(xVal > pi) xVal = pi;
	var dh = (endHeight-startHeight)*(1.0-Math.pow((1.0+Math.cos(xVal))/2.0, 2));
	var newH = startHeight + dh;

	newH = Math.round(newH > endHeight && endHeight > startHeight ? endHeight : (newH < endHeight && endHeight < startHeight ? startHeight : newH));
	newH = (newH > 0 ? newH : 0);
	node.style.height = newH + 'px';
	if(endHeight == 0 && newH == 0)
	{
		node.style.display = 'none';
	}
	
	if(xVal == pi) {
		if(cb) window.setTimeout(cb, 75);
		return;
	}
	
	window.setTimeout(function() { sinWipe(nodeId, startHeight, endHeight, dx, xVal, cb);}, 75);
}

function hideInlineSpecs(elem) {
	// Fix up the open link to do nothing while we close
	var linkElem = document.getElementById(elem + 'link');
	linkElem.onclick = function() { return false;};

	var loadingElem = document.getElementById(elem + 'loading');
	loadingElem.style.display='none';

	var openArrow =  document.getElementById(elem + 'openarrow');
	openArrow.style.display = 'none';
	var closedArrow =  document.getElementById(elem + 'closedarrow');
	closedArrow.style.display = 'inline';
	
	wipeHide2(elem,function() {linkElem.onclick = function() {showInlineSpecs(elem); return false;};});
}

function showInlineSpecs(elem) {

	// Fix up the open link to do nothing while we open
	var linkElem = document.getElementById(elem + 'link');
	linkElem.onclick = function() { return false;};
	
	var loadingElem = document.getElementById(elem + 'loading');
	loadingElem.style.display='inline';
	
	var openArrow =  document.getElementById(elem + 'openarrow');
	openArrow.style.display = 'inline';
	var closedArrow =  document.getElementById(elem + 'closedarrow');
	closedArrow.style.display = 'none';
	
	wipeShow2(elem, function() {linkElem.onclick = function() { hideInlineSpecs(elem); return false;};});
}

function fetchAndShowInlineSpecs(elem, data, limit) {

	var loadingElem = document.getElementById(elem + 'loading');
	loadingElem.innerHTML = limit;
	
	if(data == "") window.history.go(0);
	
	var specElem = document.getElementById(elem);
	specElem.innerHTML = Url.decode(data);
	
	showInlineSpecs(elem);
		
}



/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Justas | http://www.webtoolkit.info/ */
var Url = {

 	// public method for URL encoding
 	encode : function (string) {
 		 return escape(this._utf8_encode(string));
 	},

 	// public method for URL decoding
	 decode : function (string) {
 	 	return this._utf8_decode(unescape(string));
 	},

 	// private method for UTF-8 encoding
 	_utf8_encode : function (string) {
  		string = string.replace(/\r\n/g,"\n");
 	 	var utftext = "";

  		for (var n = 0; n < string.length; n++) {
   			var c = string.charCodeAt(n);
   			if (c < 128) {
    				utftext += String.fromCharCode(c);
 			} else if((c > 127) && (c < 2048)) {
  				utftext += String.fromCharCode((c >> 6) | 192);
  				utftext += String.fromCharCode((c & 63) | 128);
 			} else {
  				utftext += String.fromCharCode((c >> 12) | 224);
  				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
 	 			utftext += String.fromCharCode((c & 63) | 128);
 			}
 	}

		return utftext;
	},

 	// private method for UTF-8 decoding
 	_utf8_decode : function (utftext) {
 		 var string = "";
 		 var i = 0;
 		 var c = c1 = c2 = 0;

	//	utftext.replace("+", " ");
		
  		while ( i < utftext.length ) {
  			 c = utftext.charCodeAt(i);
   			if (c < 128) {
    				string += String.fromCharCode(c);
    				i++;
  			 } else if((c > 191) && (c < 224)) {
 				   c2 = utftext.charCodeAt(i+1);
    				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
    				i += 2;
  			 } else {
 				   c2 = utftext.charCodeAt(i+1);
    				c3 = utftext.charCodeAt(i+2);
    				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
   				 i += 3;
 			  }
		  }
		return string;
	 }
}
