function isArray(a) {
	return isObject(a) && a.constructor == Array;
}
function isFunction(a) {
	return typeof a == 'function';
}
function getTimeId () {
	var out;
	var today = new Date ();
	var rand = Math.round(1000*Math.random());
	var timest = today.getHours().toString() + today.getMinutes().toString() + today.getSeconds().toString() + today.getMilliseconds().toString();
	out = 'tmp' + timest + rand;
	return out;
}

function onopen() {
	var tounfolded = new Image();
	var tofold = new Image();
	tounfolded.src = "graphics/unfold.jpg";
	tofold.src = "graphics/fold.jpg";
	document.TimerId = new Array ();
	HidingIconScrollbarIE ();
}
function onexit (){
//	window.alert(document.ImgTimerId);
	stoptimers ();
	stopimgtimers ();
}
function swapClass(obj, cls) { 	obj.className = cls}
function InsertMinimalizeIcon (){
	document.getElementById("foldimgplace").innerHTML = '<img name="foldunfold" src="graphics/fold.jpg" onclick="roll()"  width="20" height="20" vspace="0" align="middle" alt="Click here to minimize" title="Click here to minimize" />';
}
function roll() {

	if ( !document.getElementById("pagetxt").orginal ){
		document.getElementById("pagetxt").orginal = document.getElementById("pagetxt").scrollHeight;
	}

	if (document.getElementById("pagetxt").offsetHeight == 1 ){
		unfold('pagetxt');
	}else{
    	fold('pagetxt');
	}
}
function HidingIconScrollbarIE (){
	var browser=navigator.appName;
	if ( (document.getElementById("dishdescid").offsetHeight < document.getElementById("dishdescid").scrollHeight) && (browser == "Microsoft Internet Explorer") ){
		document.getElementById("foldimgplace").width = "45px";
	}else{
		document.getElementById("foldimgplace").width = "25px";
	}
}
function unfold(id) {
	stoptimers ();
	millisec = 1000;
	var speed = Math.round(millisec / 100);
	var timer = 0;
	finish = document.getElementById("pagetxt").orginal;
		document.getElementById("dishdescid").style.overflowY = 'auto';
		for(i = 1; i < finish; i=i+5) {
			timerid = getTimeId ();
			document.TimerId[timerid] = setTimeout("changehei('" + id + "', " + i + ")",(timer * speed));
			timer++;
		}
		timerid = getTimeId ();
		document.TimerId[timerid] = setTimeout("opentxt('" + id + "')",(timer * speed));
}

function fold(id) {
	stoptimers ();
	millisec = 1000;
	var speed = Math.round(millisec / 100);
	var timer = 0;
	idhei = document.getElementById(id).offsetHeight;
	document.getElementById("pagetxt").style.overflow = 'hidden';
	    for(i = idhei; i >= 5; i=i-5) {
			timerid = getTimeId ();
			document.TimerId[timerid] = setTimeout("changehei('" + id + "', " + i + ")",(timer * speed));
			timer++;
		}
		timerid = getTimeId ();
		document.TimerId[timerid] = setTimeout("closetxt('" + id + "')",(timer * speed));
}

function stoptimers (){
	if (document.TimerId){
		for (i in document.TimerId) {
			clearTimeout ( document.TimerId[i]);
			delete (document.TimerId[i]);
		}
	}
}
function stopimgtimers (){
	var a;
	if (document.ImgTimerId){
		for (i in document.ImgTimerId) {
			clearTimeout ( document.ImgTimerId[i]);
			delete (document.ImgTimerId[i]);
			a = a + ' ' + i;
		}
	}
}
function opentxt (id){
		document.getElementById(id).style.height = document.getElementById("pagetxt").orginal + 'px';
		document.getElementById("foldimgplace").innerHTML = '<img name="foldunfold" src="graphics/fold.jpg" onclick="roll()" width="20" height="20" hspace="4" vspace="0" align="middle" alt="Click here to minimize" title="Click here to minimize" />';
		HidingIconScrollbarIE ();
}

function closetxt (id){
		document.getElementById(id).style.height = 1 + 'px';
		document.getElementById("foldimgplace").innerHTML = '<img name="foldunfold" src="graphics/unfold.jpg" onclick="roll()" width="20" height="20" vspace="0" align="middle" alt="Click here to maximize" title="Click here to maximize" />';
		HidingIconScrollbarIE ();
}
function changehei(id, i) {
		document.getElementById(id).style.height = i + 'px';
}
 