/*
function checkJavaScriptEnabled()
{
document.getElementById("jsDisabled").style.display = 'none';
}
*/

// Don't display a PNG image file containing transparency, if viewing in an IE browser prior to version 7, since it won't work properly
function ie_img_check( image_id, top_offset, height )
{
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version = b_version.split('MSIE ');
	var img_hdl;
	img_hdl = document.getElementById(image_id);
	if (browser=="Microsoft Internet Explorer") {
		// Adjust image position 
		img_hdl.style.top = top_offset;
		img_hdl.style.height = height;
		// Don't display graphic on IE versions less than 7 
		if (version[1][0] < 7) {
			img_hdl.style.display = 'none';
		} else {
			img_hdl.style.display = 'block';
		}
	} else {
		img_hdl.style.display = 'block';
	}
}

// Generic function to hide or show a div based on Javacript events
function div_show_hide( arrow_id, div_id, arrow_open_file, arrow_close_file )
{
	var arrow_hdl;
	var div_hdl;
	var state;
	arrow_hdl = document.getElementById(arrow_id);
	div_hdl = document.getElementById(div_id);
	if (div_hdl.style.display=='none') {
		div_hdl.style.display = 'block';
		arrow_hdl.src = arrow_close_file;
	} else {
		div_hdl.style.display = 'none';
		arrow_hdl.src = arrow_open_file;
	}
}

// Function to hide and show all divs in a table
function div_show_hide_all(all_arrow, parent_table, arrow_class, div_class, arrow_open_file, arrow_close_file )
{
	var do_open = (document.getElementById(all_arrow).src.indexOf(arrow_open_file) > 0);
	thdl = document.getElementById(parent_table);
	arrows = thdl.getElementsByTagName('img');
	for (i=0; i<arrows.length; i++) {
		if (arrows[i].className == arrow_class) {
			arrows[i].src = (do_open) ? arrow_close_file : arrow_open_file;
		}
	}
	divs = thdl.getElementsByTagName('div');
	for (i=0; i<divs.length; i++) {
		if (divs[i].className == div_class) {
			divs[i].style.display = (do_open) ? 'block' : 'none';
		}
	}
	document.getElementById(all_arrow).src = (do_open) ? arrow_close_file : arrow_open_file;
}

// Generic function to get a cookie
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
// Generic function to change the HMTL content of a div based on Javascript events
function change_div_content ( div_id, new_content )
{
	var div_hdl = document.getElementById(div_id);
	div_hdl.innerHTML = new_content;
}

function gen_login_hash (pw_id, hash_id) {
	var phdl = document.getElementById(pw_id);
	document.getElementById(hash_id).value = hex_md5(phdl.value+getCookie('PINEAPPLE'));
	phdl.value='';
}

// Get the current vertical scroll value of the page
function getScrollY() {
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return (scrOfY);
}
// Submit a hidden control form
function submit_ctrl( ) {
	var hdl;
	for (var i=1; i<arguments.length; i=i+2) {
		hdl = document.getElementById(arguments[i]);
		if (arguments[i+1] == '%SCROLL%') hdl.value = getScrollY();
			else hdl.value = arguments[i+1];
	}
	hdl = document.getElementById(arguments[0]);
	hdl.submit();
}
// Display confirmation prompt
function my_confirm( prompt, a_yes, a_no) {
	var resp = confirm(prompt);
	if (resp) {
	    window.location = a_yes;
	} else {
	    if (a_no != '') window.location = a_no;
	}
}

/*
function monitor_slider(display, icon, offset) {
	displayObj = document.getElementById(display);
	if (displayObj == null) alert('No Display Object');
	iconObj = document.getElementById(icon);
	if (displayObj == null) alert('No Icon Object');
	if (displayObj.addEventListener) { // Add event listeners to displayObj (Moz&co).
		displayObj.addEventListener('DOMAttrModified', function () {alert('Invoked'); iconObj.style.backgroundPosition='5px '+(displayObj.value*-offset)+'px'; }, false);
	}
	else if (displayObj.addEvent) { // Add event listeners to 'document' (IE&co).
		displayObj.attachEvent('DOMSubtreeModified', function () {iconObj.style.backgroundPosition='5px '+(displayObj.value*-offset)+'px';});
	} else alert('No Listener');
}
*/	

/*	
// DF1.1 :: domFunction 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************
//DOM-ready watcher
function domFunction(f, a)
{
	//initialise the counter
	var n = 0;
	//start the timer
	var t = setInterval(function()
	{
		//continue flag indicates whether to continue to the next iteration
		//assume that we are going unless specified otherwise
		var c = true;
		//increase the counter
		n++;
		//if DOM methods are supported, and the body element exists
		//(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
		//in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
		{
			//set the continue flag to false because other things being equal, we're not going to continue
			c = false;
			//but ... if the arguments object is there
			if(typeof a == 'object')
			{
				//iterate through the object
				for(var i in a)
				{
					//if its value is "id" and the element with the given ID doesn't exist or its value is "tag" and the specified collection has no members
					if
					(
						(a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)
					) 
					{ 
						//set the continue flag back to true because a specific element or collection doesn't exist
						c = true; 
						//no need to finish this loop
						break;
					}
				}
			}
			//if we're not continuing we can call the argument function and clear the timer
			if(!c) { f(); clearInterval(t); }
		}
		//if the timer has reached 300 (so timeout after 15 seconds)
		if(n >= 300)
		{
			//clear the timer
			clearInterval(t);
		}
	}, 10);
};
*/
