/*
*
*   TOOLBOX 1.3
*
*   Nov 14 2009
*
*** OLD function show() now render()
*** OLD function hide() now collapse()
*** NEW functions hide() and show() reset style.visibility to 
*** 'hidden' or 'visible' respectively.
*** ADDED NEW function 'dim' (for tweaking an object's opacity)
*
*/


function ge (elmt)
{
	if (window.all)
	{
	return window.all[elmt];
	} else {
	return document.getElementById(elmt);
	}


}






function render (item) 
{
	var args = render.arguments;
	
	for (var i=0; i<args.length; i++)
	{
	args[i] = (typeof args[i] == "string") ? ge(args[i]) : args[i];
	if (args[i] != null) { args[i].style.display='block'; }

	}
			
}


function collapse (item) 
{
					
	var args = collapse.arguments;
	
	for (var i=0; i<args.length; i++)
	{
	args[i] = (typeof args[i] == "string") ? ge(args[i]) : args[i];
	if (args[i] != null && args[i].style.display != 'none') { args[i].style.display='none'; }
					
	}
	
}







/*****************************************************************/


function show (item) 
{
	var args = show.arguments;
	
	for (var i=0; i<args.length; i++)
	{
	args[i] = (typeof args[i] == "string") ? ge(args[i]) : args[i];
	if (args[i] != null) { args[i].style.visibility='visible'; }

	}
			
}


function hide (item) 
{
					
	var args = hide.arguments;
	
	for (var i=0; i<args.length; i++)
	{
	args[i] = (typeof args[i] == "string") ? ge(args[i]) : args[i];
	if (args[i] != null && args[i].style.visibility != 'hidden') { args[i].style.visibility='hidden'; }
					
	}
	
}




/********************************************************/





function render_inline (item) 
{

	var args = show_inline.arguments;
	
	for (var i=0; i<args.length; i++)
	{
	args[i] = (typeof args[i] == "string") ? ge(args[i]) : args[i];
	if (args[i] != null) { args[i].style.display='inline'; }
	}
			
}


// hide*

function collapse_inline (item) 
{
					
	hide(item);
				
}



/****************************************************************/






function check_string_length (e, target, max)
{	
	
	
	target = (typeof target == "string") ? ge(target) : target;
	
	
	if (target.value.length < max || ({8:1}[e.which || e.keyCode])) 
	{
	
		return true;
	
	} else {
	
	if (target.value.length > max)
	{
	target.value = target.value.substring(0, max);
	
	}
	
	if (e.preventDefault) {e.preventDefault(); } else {return false; }
	
	} 

}




function show_message_size (max, target, display)
{
target = (typeof target == "string") ? ge(target) : target;
display = (typeof display == "string") ? ge(display) : display;
	
display.innerHTML = max - target.value.length;
display.innerHTML += " left";

}


function resetTextbox (box) {
if (box.value == box.defaultValue) {box.value = ""; }
else if (box.value == "") {box.value = box.defaultValue; }

}


// shows image when it's completely loaded...

function isComplete (img) {
img = ge(img);
if (img.complete) {
show(img);

if (/MSIE/.test(navigator.userAgent)) img.style.filter = "Alpha(opacity=100)";
else
img.style.opacity = 1;

return;
} else {
setTimeout('isComplete("' + img.id + '")', 1000);
}

}


function fadeinonComplete (img) {
img = ge(img);
if (img.complete) {
show(img);
fadeIn(img, 0.5);
return;
} else {
setTimeout('fadeinonComplete("' + img.id + '")', 1000);
}

}



var oscillator;
var opacity = 0;
var unitOpacity = 0.05;
var oscStatus = false;

function fadeIn (objct, duration) {
if (oscStatus) return false;

objct = ge(objct);

duration = (duration) ? duration : 1;
duration = duration * 1000;
interval = duration/20;


if (/MSIE/.test(navigator.userAgent)) objct.style.filter = "Alpha(opacity=0)";
else
objct.style.opacity = 0;

oscillator = setInterval ("fadeStep('" + objct.id + "')", interval);
oscStatus = true;

return;
}



function fadeOut (objct, duration) {
if (oscStatus) return false;

objct = ge(objct);
duration = (duration) ? duration : 1;
duration = duration * 1000;
interval = duration/20;

if (/MSIE/.test(navigator.userAgent)) {opacity = 1; objct.style.filter = "Alpha(opacity=100)"; }
else {
opacity = objct.style.opacity;

}


/*
if (/MSIE/.test(navigator.userAgent)) objct.style.filter = "Alpha(opacity=100)";
else
objct.style.opacity = 1;
*/
oscillator = setInterval ("fadeStepOut('" + objct.id + "')", interval);
oscStatus = true;

return;
}


function fadeStep (objct) {
if (opacity >= 1) {
clearInterval (oscillator);
oscStatus = false;
return;
} else {
opacity += unitOpacity;

if (/MSIE/.test(navigator.userAgent)) ge(objct).style.filter = "Alpha(opacity=" + opacity*100 + ")";
else
ge(objct).style.opacity = opacity;

}

}



function fadeStepOut (objct) {
if (opacity <= 0) {
opacity = 0;

if (/MSIE/.test(navigator.userAgent)) ge(objct).style.filter = "Alpha(opacity=" + opacity*100 + ")";
else
ge(objct).style.opacity = opacity;

clearInterval (oscillator);
oscStatus = false;
return;
} else {
opacity -= unitOpacity;

if (/MSIE/.test(navigator.userAgent)) ge(objct).style.filter = "Alpha(opacity=" + opacity*100 + ")";
else
ge(objct).style.opacity = opacity;

}

}



function dim (objct, by) {
if (/MSIE/.test(navigator.userAgent)) ge(objct).style.filter = "Alpha(opacity=" + by*100 + ")";
else
ge(objct).style.opacity = by;
	
return;	
}

