// <?php !! This fools phpdocumentor into parsing this file

// general utility for browsing a named array or object
function xshow(o) {
	s = '';
	for(e in o) {s += e+'='+o[e]+'\n';}
	alert( s );
}

/**
* Writes a dynamically generated list
* @param string The parameters to insert into the <select> tag
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display for the initial state of the list
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function writeDynaList( selectParams, source, key, orig_key, orig_val ) {
	var html = '\n	<select ' + selectParams + '>';
	var i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			var selected = '';
			if ((orig_key == key && orig_val == source[x][1]) || (i == 0 && orig_key != key)) {
				selected = 'selected="selected"';
			}
			html += '\n		<option value="'+source[x][1]+'" '+selected+'>'+source[x][2]+'</option>';
		}
		i++;
	}
	html += '\n	</select>';

	document.writeln( html );
}

/**
* Changes a dynamically generated list
* @param string The name of the list to change
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function changeDynaList( listname, source, key, orig_key, orig_val ) {
	var list = eval( 'document.adminForm.' + listname );

	// empty the list
	for (i in list.options.length) {
		list.options[i] = null;
	}
	i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			opt = new Option();
			opt.value = source[x][1];
			opt.text = source[x][2];

			if ((orig_key == key && orig_val == opt.value) || i == 0) {
				opt.selected = true;
			}
			list.options[i++] = opt;
		}
	}
	list.length = i;
}

/**
* Adds a select item(s) from one list to another
*/
function addSelectedToList( frmName, srcListName, tgtListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var tgtList = eval( 'form.' + tgtListName );

	var srcLen = srcList.length;
	var tgtLen = tgtList.length;
	var tgt = "x";

	//build array of target items
	/*
	for (var i=tgtLen-1; i > -1; i--) {
		tgt += "," + tgtList.options[i].value + ","
	}
	*/
	for (var i=0; i<=tgtLen-1; i++) {
		tgt += "," + tgtList.options[i].value + ","
	}

	//Pull selected resources and add them to list
	//for (var i=srcLen-1; i > -1; i--) {
	for (var i=0; i<=srcLen-1;i++) {
		if (srcList.options[i].selected && 
			tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) {
			opt = new Option( srcList.options[i].text, srcList.options[i].value );
			tgtList.options[tgtList.length] = opt;
		}
	}
}

function addSelectedTextToList( frmName, srcListName, tgtListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var tgtList = eval( 'form.' + tgtListName );

	var srcLen = srcList.length;
	var tgtLen = tgtList.length;
	var tgt = "x";

	//build array of target items
	for (var i=tgtLen-1; i > -1; i--) {
		tgt += "," + tgtList.options[i].text + ","
	}

	//Pull selected resources and add them to list
	for (var i=srcLen-1; i > -1; i--) {
		if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].text + "," ) == -1) {
			opt = new Option( srcList.options[i].text, srcList.options[i].text );
			tgtList.options[tgtList.length] = opt;
		}
	}
}

function delSelectedFromList( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=srcLen-1; i > -1; i--) {
		if (srcList.options[i].selected) {
			srcList.options[i] = null;
		}
	}
}

function delAllFromList( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=srcLen-1; i > -1; i--) {
		srcList.options[i] = null;
	}
}

function moveInList( frmName, srcListName, index, to) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var total = srcList.options.length-1;

	if (index == -1) {
		return false;
	}
	if (to == +1 && index == total) {
		return false;
	}
	if (to == -1 && index == 0) {
		return false;
	}

	var items = new Array;
	var values = new Array;

	for (i=total; i >= 0; i--) {
		items[i] = srcList.options[i].text;
		values[i] = srcList.options[i].value;
	}
	for (i = total; i >= 0; i--) {
		if (index == i) {
			srcList.options[i + to] = new Option(items[i],values[i], 0, 1);
			srcList.options[i] = new Option(items[i+to], values[i+to]);
			i--;
		} else {
			srcList.options[i] = new Option(items[i], values[i]);
	   }
	}
	srcList.focus();
}

function getSelectedOption( frmName, srcListName )
{
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	
	if (srcList != null)
	{
		i = srcList.selectedIndex;
		if (i != null && i > -1) {
			return srcList.options[i];
		} else {
			return null;
		}
	}
	
	return null;
}

function setSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=0; i < srcLen; i++) {
		srcList.options[i].selected = false;
		if (srcList.options[i].value == value) {
			srcList.options[i].selected = true;
		}
	}
}

function setSelectedValueById(srcListId, value) {
	var srcList = getObj(srcListId);
	var srcLen = srcList.length;
	for (var i=0; i < srcLen; i++) {
		srcList.options[i].selected = false;
		if (srcList.options[i].value == value) {
			srcList.options[i].selected = true;
		}
	}
}

function getSelectedValue( frmName, srcListName )
{
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	
	if (srcList != null)
	{
		i = srcList.selectedIndex;
		if (i != null && i > -1) {
			return srcList.options[i].value;
		} else {
			return null;
		}
	}
	
	return null;
}

function getSelectedValueById( frmName, srcListId )
{
	//var form = eval( 'document.' + frmName );
	//var srcList = eval( 'document.getElementById(\'' + srcListId + '\')' );
	var srcList = getObj(srcListId);
	
	if (srcList != null)
	{
		i = srcList.selectedIndex;
		if (i != null && i > -1) {
			return srcList.options[i].value;
		} else {
			return null;
		}
	}
	
	return null;
}

function getSelectedText( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].text;
	} else {
		return null;
	}
}

function getSelectedTextById( frmName, srcListId ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'document.getElementById(\'' + srcListId + '\')' );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].text;
	} else {
		return null;
	}
}

function chgSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		srcList.options[i].value = value;
		return true;
	} else {
		return false;
	}
}

// Form specific functions for editting content images

function showImageProps(base_path) {
	form = document.adminForm;
	value = getSelectedValue( 'adminForm', 'imagelist' );
	parts = value.split( '|' );
	form._source.value = parts[0];
	setSelectedValue( 'adminForm', '_align', parts[1] || '' );
	form._alt.value = parts[2] || '';
	form._border.value = parts[3] || '0';

	previewImage( 'imagelist', 'view_imagelist', base_path );
}

function applyImageProps() {
	form = document.adminForm;
	if (!getSelectedValue( 'adminForm', 'imagelist' )) {
		alert( "Select and image from the list" );
		return;
	}
	value = form._source.value + '|'
	+ getSelectedValue( 'adminForm', '_align' ) + '|'
	+ form._alt.value + '|'
	+ parseInt( form._border.value );
	chgSelectedValue( 'adminForm', 'imagelist', value );
}

function previewImage( list, image, base_path ) {
	form = document.adminForm;
	srcList = eval( "form." + list );
	srcImage = eval( "document." + image );
	var fileName = srcList.options[srcList.selectedIndex].text;
	var fileName2 = srcList.options[srcList.selectedIndex].value;
	if (fileName.length == 0 || fileName2.length == 0) {
		srcImage.src = 'images/blank.gif';
	} else {
		srcImage.src = base_path + fileName;
	}
}

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
*/
function checkAll( n ) {
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.cb' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}

/**
*/
function listItemTask( id, task ) {
	var f = document.adminForm;
	cb = eval( 'f.' + id );
	if (cb) {
		cb.checked = true;
		submitbutton(task);
	}
	return false;
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

/**
* Getting radio button that is selected.
*/
function getSelected(allbuttons){
	for (i=0;i<allbuttons.length;i++) {
		if (allbuttons[i].checked) {
			return allbuttons[i].value
		}
	}
}

// JS Calendar
var calendar = null; 

function selected(cal, date) {
	cal.sel.value = date; 
}

function closeHandler(cal) {
	cal.hide();			// hide the calendar
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.

function showCalendar(id) {
	var el = document.getElementById(id);

	if (calendar != null) {
		calendar.hide();	
		calendar.parseDate(el.value);
	} else {
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;	
		cal.setRange(1900, 2070);
		calendar.create();	
	}
	calendar.sel = el;	
	calendar.showAtElement(el);

	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}

/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// LTrim(string) : Returns a copy of a string without leading spaces.
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}

/**
* Get position of a object
*/
function findObjectPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findObjectPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

/**
* Find a object by id
*/
function getObj(name)
{
  if (document.getElementById) {
       return document.getElementById(name);
  } else if (document.all) {
       return document.all[name];
  } else if (document.layers) {
       if (document.layers[name]) {
          return document.layers[name];
       } else {
          return document.layers.testP.layers[name];
       }
  }
}

function copy_clip(meintext)
{
 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
	   clip.setData(trans,null,clipid.kGlobalClipboard);
	   return true;
   
   }
   return false;
}

function checkBrowser()
{
    var theAgent = navigator.userAgent.toLowerCase();
    if(theAgent.indexOf("msie") != -1){
        if(theAgent.indexOf("opera") != -1){
            return "opera";
        }
        else{
            return "ie";
        }
    }
    else if(theAgent.indexOf("netscape") != -1){
        return "netscape";
    }
    else if(theAgent.indexOf("firefox") != -1){
        return "firefox";
    }
    else if(theAgent.indexOf("mozilla/5.0") != -1){
        return "mozilla";
    }
    else if(theAgent.indexOf("\/") != -1){
        if (theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla'){
            return navigator.userAgent.substr(0,theAgent.indexOf('\/'));
        }
        else{
            return "netscape";
        }
    }
    else if(theAgent.indexOf(' ') != -1){
        return navigator.userAgent.substr(0,theAgent.indexOf(' '));
    }
    else{
        return navigator.userAgent;
    }
}

var messageDiv = null;
function showMsgBox(objid, msg) {
        var obj = getObj(objid);
        var x = findObjectPosX(obj);
        var y = findObjectPosY(obj);

        var scrollPos = 0;
        if (checkBrowser() != "ie") {
            scrollPos = obj.scrollTop;
        }

        if (messageDiv) messageDiv.parentNode.removeChild(messageDiv);
        messageDiv = document.createElement('DIV');
        messageDiv.className = "suggestion_box";
        messageDiv.style.display = "inline";
        messageDiv.style.position = 'absolute';
        messageDiv.style.left = x + 'px';
        messageDiv.style.top = (y+16-scrollPos) + 'px';
        messageDiv.innerHTML = msg;
        document.body.appendChild(messageDiv);
}

function popup(mylink, windowname, window_width, window_heigth, resizable, scrollbars, status, menubar, toolbar, location)
{
	if (!window.focus) return true;

	var parms =	"top=" + ((screen.height - window_heigth) / 2) + "," +
			"left=" + ((screen.width - window_width) / 2) + "," +
			"width=" + window_width + "," +
			"height=" + window_heigth + "," +
			"resizable=" + resizable + "," +
			"scrollbars=" + scrollbars + "," +
			"status=" + status + "," +
			"menubar=" + menubar + "," +
			"toolbar=" + toolbar + "," +			
			"location=" + location;
	
	var newwindow = window.open(mylink, windowname, parms);
	if (newwindow) newwindow.focus();

	return true;
}

function inputbox_navigation(obj, next_obj,ev) {
	if(obj.maxLength==obj.value.length) {		
		var next_obj = document.getElementById(next_obj);
		var key = ev.keyCode;
		if (key!=9 && key!=16) {
			next_obj.focus();
			next_obj.select();
		}
	}
}

function strip_inputbox_non_digits(obj) {
	obj.value = strip_non_digits(obj.value);
}

function uppercase_inputbox(obj) {
	obj.value = obj.value.toUpperCase();
}

function strip_non_digits(n) {
	var s = String(n);
	var re = /\D/g;
	return s.replace(re,"");
}

function hide_object(id) {
	
	obj = document.getElementById(id);
	if(obj!=null) {	
		obj.style.visibility='hidden';
		obj.style.position = 'fixed'; 
		obj.style.display ='none';
	}
}

function show_object(id) {
  	
  	obj = document.getElementById(id);
	if(obj!=null) {
		obj.style.display= '';
		obj.style.visibility='visible';
		obj.style.position = 'relative'; 
	}
}

// get all html object  in a html form and generate a GET string of their values
function get_form_objs(formname)
{
	var obj = getObj(formname);
	
	return get_children_node_objs(obj);;
}
 
function get_children_node_objs(obj)
{
	if (!obj.hasChildNodes() || !obj.childNodes || obj.childNodes.length==0) return "";
	
	var getstr = "";
	for (var i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].tagName == "INPUT")
		{
			if (obj.childNodes[i].type == "text" || obj.childNodes[i].type == "hidden")
			{
				getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
			}
			if (obj.childNodes[i].type == "checkbox")
			{
				if (obj.childNodes[i].checked)
				{
					getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				}
				else
				{
					getstr += obj.childNodes[i].name + "=&";
				}
			}
			if (obj.childNodes[i].type == "radio")
			{
				if (obj.childNodes[i].checked)
				{
					getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				}
			}
		}
		else if (obj.childNodes[i].tagName == "SELECT")
		{
			var sel = obj.childNodes[i];
			getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
		}
		else if (obj.childNodes[i].hasChildNodes())
		{
			var child_str = get_children_node_objs(obj.childNodes[i]);
			getstr += child_str;
		} 
	}
	
	return getstr;
}

// get the parent window in a popup window
function get_parent_window()
{
    var parentWindow = null;
    if (window.dialogArguments) {
        parentWindow = dialogArguments;
    } else if (parent.window.dialogArguments) {
        parentWindow = parent.window.parentWindow;
    } else if (window.opener) {
        parentWindow = window.opener;
    } else if (parent.window.opener) {
        parentWindow = parent.window.parentWindow;
    }
    return parentWindow;
}

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can not get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can not get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/**
 *
 */
function confirm_submit(message)
{
	var agree = confirm(message);
	
	if (agree) return true ;
	else return false ;
}


/** BEGIN: THE FOLLOWING FUNCTIONS BELOW ARE USED TO CENTER OUR DIV **/

/** BEGIN: EXAMPLE **
<style type="text/css">
#div_id{
	position: relative; // Needed for Safari
	text-align: left;
	width: 200px;
	background-color: #eeeeee;
	border:1px solid #666666;
	padding: 10px;
	color:#333333;
	font-family:verdana,arial,helvetica,sans-serif;
	font-size:12px;
	font-weight:bold;
	z-index:1000;
	display:none;
}
</style>

<div id="div_id">message</div>

<script language="JavaScript">
	display_div_message_box_id('div_id');
	
	window.onload = function()
	{
		display_div_message_box_id('div_id');
	}
	
	window.onresize = function()
	{
		display_div_message_box_id('div_id');
	}
</script>

** END: EXAMPLE **/

function get_window_height()
{
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number')
	{
		windowHeight = window.innerHeight;
	}
	else
	{
		if (document.documentElement && document.documentElement.clientHeight)
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else
		{
			if (document.body && document.body.clientHeight)
			{
				windowHeight = document.body.clientHeight;
			}
		}
	}
	
	return windowHeight;
}

function get_window_width()
{
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number')
	{
		windowWidth = window.innerWidth;
	}
	else
	{
		if (document.documentElement && document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth;
		}
		else
		{
			if (document.body && document.body.clientWidth)
			{
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}

function get_browser_width()
{
	var btype=checkBrowser();
	if (btype=='ie') {
		return document.body.clientWidth;
	} else {
		return document.documentElement.clientWidth;
	}
}

function set_content_height_width(element_id)
{
	if (document.getElementById)
	{
		var windowHeight = get_window_height();
		var windowWidth = get_window_width();
		if (windowHeight > 0)
		{
			var body = document.getElementsByTagName('body')[0];
			var contentElement = document.getElementById(element_id);
			
			var contentHeight = contentElement.offsetHeight;
			var contentWidth = contentElement.offsetWidth;
			
			if (windowHeight - contentHeight > 0)
			{
				contentElement.style.position = 'absolute'; // 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + body.scrollTop + 'px';
				contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + body.scrollLeft +'px';
			}
			else
			{
				contentElement.style.position = 'static';
			}
			
			// Re-assigning the child
			contentElement.parentNode.removeChild(contentElement);
			body.insertBefore(contentElement, body.firstChild);
		}
	}	
}

function display_div_message_box_id(div_id)
{
	getObj(div_id).style.display = 'block';
	set_content_height_width(div_id);
}

/** END: THE FOLLOWING FUNCTIONS BELOW ARE USED TO CENTER OUR DIV **/

function display_div_by_id(div_id)
{
	getObj(div_id).style.display = 'block';
}

function hide_div_by_id(div_id)
{
	getObj(div_id).style.display = 'none';
}

function switchTab(n, navid, tbid) 
{
	var nc=document.getElementsByName(navid);
	if (nc && nc.length>0) {
		var t=document.getElementsByName(tbid);
		for(i=0;i<nc.length;i++) {
			nc.item(i).className="pe-tab-off";
			t.item(i).className="pe-hide-table";
		}
		nc.item(n).className="pe-tab-on";
		t.item(n).className="pe-tab-content pe-show-table";
	}
}

var tinyMCEmode = true;
function toogleEditorMode(sEditorID) {
   					 try { 
        				if(tinyMCEmode) {
           							 //tinyMCE.removeMCEControl(tinyMCE.getInstanceById(sEditorID));
									tinyMCE.execCommand('mceRemoveControl',false,sEditorID)
            						tinyMCEmode = false;
       						 } else {
            						//tinyMCE.addMCEControl(document.getElementById('pagecontent'), sEditorID);
									tinyMCE.execCommand("mceAddControl", true, sEditorID); 
           							 tinyMCEmode = true;
       						 }
    				} catch(e) {
       					// alert(e);
   					 }
				}


