/*                                          simple-complex tinySimple CMS v. 0.9.60 - www.tinysimple.net
*       javascriptBasics
####### DISTRIBUTED UNDER THE LGPL LICENSE ###################################################################
# The library javascriptBasics delivers basic javascript functions.
# This library was originally created as part of the program simple-complex tinySimple CMS v. 0.9.60
####### Copyright (C) 2007-2009 Jacob Friis Mathiasen ########################################################
# This library is free software; you can redistribute it and/or modify it under the terms of the
# GNU Lesser General Public License as published by the Free Software Foundation;
# either version 3 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with this library;
# if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA (or check http://www.gnu.org/licenses/lgpl.html).
# Copyright holder contact info:
# Email: dev.simplecomplex@gmail.com. Paper mail: Jacob Friis Mathiasen, Sk 38, DK-1709 V, Copenhagen, Denmark
############################################################################################################*/
/*///// javascriptBasics ///////////////////////////////////////////////////////////////////////////////////*/

//	document.getElementById() and document.forms[].elements[] substititue ------------------------------------
/*ref|null*/ function getDocElm(identifier_or_formId, fieldId, suppressError) {
    var ref;
	if(fieldId !== undefined && fieldId != null) { // form elements
	    if( (ref = document.forms[identifier_or_formId].elements[fieldId]) !== undefined
	    && ref != null)  return ref;
	    else if(DEBUG !== undefined && DEBUG > 0
	    && (!(suppressError !== undefined) || suppressError == false) ) {
	        if(document.forms[identifier_or_formId] !== undefined)
	            alert("form [" + identifier_or_formId + "] has no element named [" + fieldId + "]");
	        else  alert("form [" + identifier_or_formId + "] does not exist,"
	               + " nor does its element named [" + fieldId + "]");
	    }   
	}
    else {
        if( (ref = document.getElementById(identifier_or_formId)) !== undefined && ref != null)  return ref;
        else if(DEBUG !== undefined && DEBUG > 0
        && (!(suppressError !== undefined) || suppressError == false) ) {
            alert("document element [" + identifier_or_formId + "] does not exist");
        }
    }
    return null;
}

//  checkers -------------------------------------------------------------------------------------------------
//  defined ? --------------------------------------------------------
/*bool*/ function isDefined(subj) {  return subj !== undefined;  }
//  not defined ? ----------------------------------------------------
/*bool*/ function notDefined(subj) {  return !(subj !== undefined);  }
//  undefined | null ? -----------------------------------------------
/*bool*/ function isNada(subj) {
    if(subj !== undefined && subj !== null) { return false; }
    else { return true; }
} 
var isNothing = isNada;
//  true | 1 | 1.000 ? -----------------------------------------------
/*bool*/ function isTrue(subj) {   
    if(typeof subj === "boolean") {  if(subj === true) {  return true;  }  }
    else if(typeof subj === "number") {  if(subj === 1) {  return true;  }  }
    return false;
}
//  false | 0 | 0.000 | "" ? -----------------------------------------
/*bool*/ function isFalse(subj) {
    if(subj !== undefined) { 
        if(subj === null) {  return true;  }
        if(typeof subj === "boolean") {  
            if(subj === false) { return true; }  else { return false; } 
        }
        if(typeof subj === "number") {
            if(subj === 0) { return true; }  else { return false; }  
        }
        if(typeof subj === "string" && subj.length > 0) {  return false;  }
        return false;
    }
    return true;
}
//  "non-empty" ? ----------------------------------------------------
/*bool*/ function nonEmptyString(subj) {   
    if(subj !== undefined && subj !== null && typeof subj === "string" && subj.length > 0) { return true; }
    return false;
} 
//  positive number and zero) ----------------------------------------
/*bool*/ function nonNegative(subj) {   
    if(subj !== undefined && subj !== null && typeof subj === "number" && isFinite(subj) && subj > -1) { 
        return true;  }
    return false;
} 
//  type -------------------------------------------------------------
/*bool*/ function isString(subj) {
    if(subj !== undefined && subj !== null) { return typeof subj === "string"; }
    return false;
}
/*bool*/ function isNumber(subj) {
    if(subj !== undefined && subj !== null) { return (typeof subj === "number" && isFinite(subj)); }
    return false;
}
/*bool*/ function isArray(subj) { // not precise for associative arrays (assoc. arrays are plain objects)
    return subj instanceof Array;
}

//  count (public) object properties -------------------------------------------------------------------------
//  also counts Arrays
/*int*/ function count(obj) {
    if(obj !== undefined && obj !== null) {
        if(typeof obj === "string") {  return obj.length;  } // gecko can do without, ie cant
        var length = 0;  var key;  
        for(key in obj) {
            if(obj.hasOwnProperty(key)) {
                if(typeof obj[key] === "function") { } 
                else {  ++length;  }
            }
        }
        return length;
    }
    return 0;
}
var objectLength = count; // alias


//  javascript associative arrays are not safe ---------------------------------------------------------------
//  this Map is an alternative
//  arg styles: {"one":"uno", "two":"dos", "three":"tres"}, mapName | new Array("uno", "dos", "tres"), mapName
/*class*/ function Map(/*obj|arr*/obj_arr, /*str*/mapName) { 
    //this.name = "no-name";
    this.name = mapName || "no-name";
    var _length = 0;    
    var _assoc = new Array(); // private associate array
    var _numToName = new Array(); // private numeric array, indexex points to assocs keys
    var _pointer = 0;
    var _em = "Map[" + this.name + "]:"; // error message prefix
    
    //  traversers -----------------------------------------------------------------------
    //  PHP style concept, except the PHP equivalents cannot return key ;-)
    /*mixed|false*/ this.reset = function() {  _pointer = 0;  }
    /*mixed|false*/ this.current = function(returnName) {
        if(_length == 0) {  return false;  }   
        if(isTrue(returnName)) {  return _numToName[_pointer];  }
        return _assoc[ _numToName[_pointer] ];
    }
    /*mixed|false*/ this.next = function(returnName) {
        if(_length == 0 || _pointer > _length - 2) {  return false;  }   
        if(isTrue(returnName)) {  return _numToName[++_pointer];  }
        return _assoc[ _numToName[++_pointer] ];
    }
    /*mixed|false*/ this.prev = function(returnName) {
        if(_length == 0 || _pointer < 1) {  return false;  }   
        if(isTrue(returnName)) {  return _numToName[--_pointer];  }
        return _assoc[ _numToName[--_pointer] ];
    }
    /*mixed|false*/ this.end = function(returnName) {
        if(_length == 0) {  return false;  }  _pointer = _length - 1;  
        if(isTrue(returnName)) {  return _numToName[_pointer];  }
        return _assoc[ _numToName[_pointer] ];
    }
    
    //  getters --------------------------------------------------------------------------
    /*int*/ this.length = function() {  return _length;  }; this.count = this.length; // alias
    
    //  get value ----------------------------------------------------
    //  g, get, getName, getByName
    /*mixed|null*/ this.get = function(/*str*/name) {
        if(!nonEmptyString(name)) {
            if(DEBUG > 0) {  alert(_em+"get: arg name is not a valid string");  }  
            return null;  
        }
        if(_assoc[ name ] !== undefined) {  return _assoc[ name ];  }
        return null; 
    }; this.g = this.get;  this.get = this.get;  this.getByName = this.get;  this.getName = this.get;
    
    //  getKey, getByNumber, getByNum, getNum
    /*mixed|null*/ this.getByNumber = function(/*int*/number) {
        if(!nonNegative(number)) {  
            if(DEBUG > 0) {
                alert(_em+"getByNumber: arg number["+number+"] is not a valid positive integer");
            }
            return null;  
        }
        if(number >= _length)  return null;
        else  return _assoc[ _numToName[number] ];
    }; this.getByNum = this.getByNumber;  this.getNum = this.getByNumber;  this.getKey = this.getByNumber;
    
    //  get key ------------------------------------------------------
    /*int|-1*/ this.indexOfName = function(/*str*/name) {
        if(!nonEmptyString(name)) {  
            if(DEBUG > 0) {  alert(_em+"indexOfName: arg name is not a valid string");  }  
        }
        else if(_assoc[name] !== undefined) {
            for(var index = 0; index < _length; index++) {
                if(_numToName[index] == name) {  return index;  }
            }
            if(DEBUG > 0){
                alert(_em+"indexOfName: _numToName array is corrupt, missing index for name["+name+"]");  
            }  
        }
        return -1;
    }   
    
    /*str|null*/ this.nameOfIndex = function(/*int*/number) {
        if(!nonNegative(number)) {  
            if(DEBUG > 0) { alert(_em+"nameOfIndex: arg number["+number+"] is not a valid positive integer");} 
        }
        else if(number < _length) {  return _numToName[number];  }
        else if(DEBUG > 1) {
            alert(_em+"nameOfIndex: arg number["+number+"] is larger"
                    + " than map length["+_length+"] - not acceptable in debug mode[>1]"); 
        } 
        return null;
    }
    
    //  setters --------------------------------------------------------------------------
    //  s, set, setName, setByName
    /*bool*/ this.set = function(/*str*/name, value) {
        if(!nonEmptyString(name)) {  
            if(DEBUG > 0) {  alert(_em+"set: arg name is not a valid string");  }
            return false;  
        }
        if(notDefined(value)) { 
            if(DEBUG < 2) {  value = null;  }
            else {  alert(_em+"set: arg value for bucket name[" + name + "] is undefined"
                            + " - not allowed in debug mode[>1] (in less debug evaluates to null)");
                return false;  
            }
        }
        if(_assoc[name] !== undefined) { } // overwrites existing, num-to-name relation not changed
        else  _numToName[_length++] = name; // append num-to-name relation
        _assoc[name] = value;  return true;
    }; this.s = this.set;  this.setByName = this.set;  this.setName = this.set;  
    
    //  setKey, setByNumber, setByNum, setNum, 
    /*bool*/ this.setByNumber = function(/*int*/number, value) {
        if(!nonNegative(number)) {  
            if(DEBUG > 0) { alert(_em+"setByNumber: arg number["+number+"] is not a valid positive integer");}
            return false;  
        }
        if(number < _length) {  _assoc[ _numToName[number] ] = value;  }
        else if(number >= _length) {
            if(number > _length && DEBUG > 1) {  
                alert(_em+"setByNumber: arg number["+number+"] is larger than map length["+_length
                        + "] - not acceptable in debug mode[>1]");  
                return false;  
            }
            _numToName[_length] = _length;  _assoc["" + _length + ""] = value; // string key
            ++_length;     
        }
        return true;
    }; this.setByNum = this.setByNumber;  this.setNum = this.setByNumber;  this.setKey = this.setByNumber;
    
    //  is set? ------------------------------------------------------
    //  isset, issetName
    /*bool*/ this.issetName = function(/*str*/name) {
        if(!nonEmptyString(name)) {
            if(DEBUG > 0) {  alert(_em+"issetName: arg name is not a valid string");  }
            return false;  
        }
        if(_assoc[ name ] !== undefined) {  return true;  }
        return false;
    }; this.isset = this.issetName;
    
    //  issetKey, issetIndex, issetNumber
    /*bool*/ this.issetNumber = function(/*int*/number) {
        if(!nonNegative(number)) {
            if(DEBUG > 0) { alert(_em+"issetNumber: arg number["+number+"] is not a valid positive integer");}  
            return false;  
        }
        if(number >= _length) {  return false;  }
        return true;
    }; this.issetKey = this.issetNumber;  this.issetIndex = this.issetNumber;
    
    //  unsetters ------------------------------------------------------------------------
    //  unset, unsetName
    /*bool*/ this.unsetName = function(/*str*/name) {
        if(!nonEmptyString(name)) {
            if(DEBUG > 0) {  alert(_em+"unsetName: arg name is not a valid string");  }
            return false;  
        }
        if(_assoc[name] !== undefined) {
            _numToName.splice( this.indexOfName(name) , 1);
            delete _assoc[name];
            --_length;
        }
        return true;
    }; this.unset = this.unsetName;
    
    //  unsetKey, unsetNumber
    /*bool*/ this.unsetNumber = function(/*str*/number) {
        if(!nonNegative(number)) {  if(DEBUG > 0)  alert(_em+"unsetNumber:"
                + " arg number is not a valid positive integer");  return false;  }
        if(number < _length)  return this.unsetName( _numToName[number] );
        else if(DEBUG > 1)  alert(_em+"unsetNumber: arg number[" + number + "] is larger"
                + " than map length[" + _length + "] - not acceptable in debug mode[>1]");
        return false;
    }; this.unsetKey = this.unsetNumber;
    
    //  constructor ----------------------------------------------------------------------
    //  name must go first, otherwise the object wont know its name when erring in the add method
    if(mapName !== undefined && mapName != null)  this.name = mapName; 
    if(obj_arr !== undefined && obj_arr != null) {
        for(var name in obj_arr)  this.set(name, obj_arr[name]);
    } 
}

//  intval - integer value -----------------------------------------------------------------------------------
/*int*/ function intval(a) {
    if(a !== undefined && a !== null) {
        if(typeof a === "number" && isFinite(a))  { return a; }
        else if(typeof a === "boolean") {  if(a === true) { return 1; }  else { return 0; }  }
        else if(typeof a === "string") {
            if(isNaN(parseInt(a, 10))) { return 0; }
            else { return parseInt(a, 10); }
        }
        return 0;
    }  
    return 0;
}

//	isset ----------------------------------------------------------------------------------------------------
/*bool*/ function isset(var_or_varAndIndex) {
	try {
		if(var_or_varAndIndex !== undefined) { return true; }
		else { return false; }
	}
	catch(undefinedArrayBucket) {  return false;  }	
}

//  numeric base ---------------------------------------------------------------------------------------------
/*str*/ function dec2hex(decimal)  {  return decimal.toString(16);  }
/*int*/ function hex2dec(hex)  {  return parseInt(hex, 16);  }

//	trim -----------------------------------------------------------------------------------------------------
String.prototype.trim = function() {
    return this.replace(/(^\s+)|(\s+$)/g, "");
};
/*str*/ function trim(string) {
	return ("" + string + "").replace(/(^\s+)|(\s+$)/g, "");
}

//	newline to break -----------------------------------------------------------------------------------------
String.prototype.nl2br = function() {
    return this.replace(/[\r]?[\n]/g, "<br/>\n");
};
/*str*/ function nl2br(string) {
	return ("" + string + "").replace(/[\r]?[\n]/g, "<br/>\n");
}

/*str*/ function doubleNewlineP_singleNewlineBr(string) {
    string = ("" + string + "").replace(/([^\n])[\r]?[\n]([^\r\n])/g, "$1<br/>\n$2");
	return string.replace(/[\r]?[\n][\r]?[\n]/g, "</p><p>\n");
}

//	first letter to uppercase --------------------------------------------------------------------------------
String.prototype.ucfirst = function() {
    var ucfirstStr = "";
    if(this.length > 0)  ucfirstStr += this.substr(0, 1).toUpperCase();
    if(this.length > 1)  ucfirstStr += this.substr(1);
    return ucfirstStr;
};
/*str*/ function ucfirst(string) {
    if(!string) return "";
    var strLength = ("" + string + "").length;
    var ucfirstStr = "";
    if(strLength > 0)  ucfirstStr += string.substr(0, 1).toUpperCase();
    if(strLength > 1)  ucfirstStr += string.substr(1);
    return ucfirstStr;
}

//  date/time ------------------------------------------------------------------------------------------------

//  unix timestamp
/*int*/ function time(/*optionals*//*int|dateformat str*/year, /*int*/month, /*int*/date) {
    if(year !== undefined && year != null) {
        if(typeof year == "number" && isFinite(year)
        && month !== undefined && month != null && date !== undefined && date != null)
            return parseInt(new Date((year, month - 1, date).getTime() / 1000), 10);
        else if(typeof year == "string") {
            var params = year.split("-");
            return parseInt((new Date(
                    parseInt(params[0],10), parseInt(params[1],10) - 1,
                    parseInt(params[2]),10).getTime() / 1000), 10);
        }
    }
    return parseInt((new Date().getTime() / 1000), 10);  
}  

/*str|int*/ function date_date(/*optionals:seconds*/timestamp, asInteger/*=false*/) {
    if(timestamp !== undefined && timestamp != null)  var date = new Date(timestamp * 1000);
    else  var date = new Date();
    if(asInteger !== undefined && asInteger == true) {  var returnAsInt = true;  var delim = "";  }
    else {  var returnAsInt = false;  var delim = "-";  }
    var monthDay;  var dateDay;
    var currentDay = "" + date.getFullYear() + "";
    if( (monthDay = date.getMonth() + 1) < 10)  monthDay = "0" + monthDay + "";
    currentDay += delim + monthDay;
    if( (dateDay = date.getDate()) < 10)  dateDay = "0" + dateDay + "";
    currentDay += delim + dateDay;
    if(returnAsInt == false)  return currentDay;
    else  return parseInt(currentDay, 10);
}

/*int*/ function days_ago(/*optional:seconds*/timestamp) {
    if(timestamp !== undefined && timestamp != null) {
        var todayDate = date_date(null, true);  var otherDate = date_date(timestamp, true);
    }
    else  return 0; // today
    if(otherDate == todayDate)  return 0;
    if(otherDate < todayDate)  return parseInt(Math.floor((time() - timestamp) / (24*60*60)), 10);
    else  return - parseInt(Math.ceil((timestamp - time()) / (24*60*60)), 10);
}

//	cookie ---------------------------------------------------------------------------------------------------
function setCookie(name, value, /*optional*/ seconds) {
    //  for session:  omit parameter, or "" ors "session"
    //  delete:  value = "", seconds = -1
    var path = "/";
    var expires = "; expires=";   //  no expires= if session, else IE gets confused
    if(!seconds || seconds == "" || seconds == "session")   expires = "";
    else {
        var date = new Date();
        if(seconds == -1)  date.setTime(date.getTime() - (1000 * 1000));
        else  date.setTime(date.getTime() + (seconds * 1000));
        expires += date.toGMTString();
    }
    document.cookie = name +"=" + value + expires + "; path=" + path;
}

function deleteCookie(name) {
    setCookie(name, "", -1);
}

/*str|null*/ function readCookie(name) {
//  A rewrite of Quirksmode�s (www.quirksmode.org). Muchas gracias
    var nameEqual = name + "=";
    var cookieArr = document.cookie.split(";");
    var currentCookie;
    for(var i = 0; i < cookieArr.length; i++) {
        currentCookie = cookieArr[i];
        while(currentCookie.charAt(0) == " ") {
            currentCookie = currentCookie.substring(1, currentCookie.length);
        }
		if(currentCookie.indexOf(nameEqual) == 0)
			return currentCookie.substring(nameEqual.length, currentCookie.length);
	}
	return null;
}

/*bool*/ function issetCookie(cookieName) {
    var isSet = false;   var cookieArr = document.cookie.split(";");   var currentCookie;
    for(var i = 0; i < cookieArr.length; i++) {
        currentCookie = cookieArr[i];
        while(currentCookie.charAt(0) == " ") {
            currentCookie = currentCookie.substring(1, currentCookie.length);
        }
        if(currentCookie.indexOf(cookieName + "=") == 0) {
            isSet = true;
            break;
        }
    }
    return isSet;
}

//	count characters -----------------------------------------------------------------------------------------
function charCount_display(formName, fieldName, displayName) {
    var form = getDocElm(formName);
    var str = trim(form.elements[ fieldName ].value).replace(/[\r]?[\n]/g, " ");
    if(str.length == 0)  getDocElm( displayName ).innerHTML = "" + 0 + "&thinsp;&#183;" + 0 + "";
	else  getDocElm( displayName ).innerHTML
            = "" + str.length + "&thinsp;&#183;" + (str.split(" ").length) + "";
}

/*str*/ function charCount_html(str) {
	return str.replace(/&[^;]+;/g, " ").length;
}

//	randomizers ----------------------------------------------------------------------------------------------
/*int*/ function rand(/*int*/floor, /*int*/ceiling) {
	return floor + Math.floor( ( Math.random() * ( (ceiling - floor) + 1 ) ) + 1 ) - 1;
}

/*str*/ function randomHexString(length) {
	var randomStr = "";  var randValue;
    for(var i = 0; i < length; i++) {
        if( (randValue = rand(0, 15)) < 10)  randomStr += "" + randValue + "";
		else  randomStr += String.fromCharCode(randValue + 87);
    }
    return randomStr;
}

/*void*/ function deBlurMailLink(linkId, seed, title, omitVisibleTitle) {
    var default_titlePrefix = "email: ";
    var docElm_mailLink = getDocElm(linkId);
    var cipher = docElm_mailLink.getAttribute("href");
    var lastSlash;  // ie bug
    if( (lastSlash = cipher.lastIndexOf("/")) > -1)  cipher = cipher.substr(lastSlash + 1);
    var hexStringed = "";  var cipherLength = cipher.length;
    for(var i = 0; i < cipherLength; i++)
        hexStringed += String.fromCharCode(parseInt(cipher.charAt(i) + cipher.charAt(++i), 16) - seed);
    var cipherParts = hexStringed.replace(/__/g, ".").split("|");
    var plainText = cipherParts[1] + "@" + cipherParts[0];
    docElm_mailLink.setAttribute("href", "mailto:" + plainText);
    if(title == null || title.length == 0)  title = default_titlePrefix + plainText;
    docElm_mailLink.setAttribute("title", title);
    if(omitVisibleTitle)  return;
    else  docElm_mailLink.innerHTML = plainText;
}

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*//*                                          simple-complex tinySimple CMS v. 0.9.60 - www.tinysimple.net
*       javascriptForm
####### DISTRIBUTED UNDER THE LGPL LICENSE ###################################################################
# The library javascriptForm delivers javascript form functions.
# This library was originally created as part of the program simple-complex tinySimple CMS v. 0.9.60
####### Copyright (C) 2007-2009 Jacob Friis Mathiasen ########################################################
# This library is free software; you can redistribute it and/or modify it under the terms of the
# GNU Lesser General Public License as published by the Free Software Foundation;
# either version 3 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with this library;
# if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA (or check http://www.gnu.org/licenses/lgpl.html).
# Copyright holder contact info:
# Email: dev.simplecomplex@gmail.com. Paper mail: Jacob Friis Mathiasen, Sk 38, DK-1709 V, Copenhagen, Denmark
############################################################################################################*/
/*///// javascriptForm /////////////////////////////////////////////////////////////////////////////////////*/

/*
var formLabel_titleInfo_elements = new Array();
 function formLabel_titleInfo(identifier, titleInfoMarker) {
	var docElm_label = getDocElm(identifier);  var pureLabelText;
	if(titleInfoMarker !== undefined) { // display title info marker
		pureLabelText = docElm_label.innerHTML.replace(/&nbsp;$/, "");
		formLabel_titleInfo_elements[identifier] = pureLabelText;
		docElm_label.innerHTML = pureLabelText + titleInfoMarker;
	}
	else // remove title info marker
		docElm_label.innerHTML = formLabel_titleInfo_elements[identifier];
}
*/


//	get/set value of non-textual fields ----------------------------------------------------------------------

//	radio --------------------------------------------------------------------------------
//  - thanks for inspiration to Shailesh N. Humbad, www.somacon.com/p143.php
/*str*/ function form_getRadioValue(/*str|ref*/formId_or_formRef, /*str|int*/fieldId_or_fieldIndex) {
	if(isString(formId_or_formRef))
		var radio = getDocElm(formId_or_formRef, fieldId_or_fieldIndex);
	else  var radio = formId_or_formRef.elements[fieldId_or_fieldIndex];
	var radioLength = radio.length;
	for(var i = 0; i < radioLength; i++) {
		if(radio[i].checked == true)  return "" + radio[i].value + "";
	}
	return "";
}
/*bool*/ function form_setRadioValue(/*str|ref*/formId_or_formRef, /*str|int*/fieldId_or_fieldIndex,
		/*str|int*/fieldValue) {	
	if(isString(formId_or_formRef))
		var radio = getDocElm(formId_or_formRef, fieldId_or_fieldIndex);
	else  var radio = formId_or_formRef.elements[fieldId_or_fieldIndex];
	var radioLength = radio.length;  
	fieldValue = "" + fieldValue + ""; // turn int to string
	var success_foundValue = false;	
	for(var i = 0; i < radioLength; i++) {
		if(radio[i].value == fieldValue) {
			success_foundValue = true;  radio[i].checked = true;
		}
		else  radio[i].checked = false;
	}
	return success_foundValue;
}

//	select -------------------------------------------------------------------------------
/*str*/ function form_getSelectValue(/*str|ref*/formId_or_formRef, /*str|int*/fieldId_or_fieldIndex) {
	if(isString(formId_or_formRef))
		var select = getDocElm(formId_or_formRef, fieldId_or_fieldIndex);
	else  var select = formId_or_formRef.elements[fieldId_or_fieldIndex];
	var optionKey = -1;
	if( (optionKey = select.selectedIndex) > -1)  return "" + select[optionKey].value + "";
	return "";
}
/*bool*/ function form_setSelectValue(/*str|ref*/formId_or_formRef, /*str|int*/fieldId_or_fieldIndex,
		/*str|int*/fieldValue) {
	if(isString(formId_or_formRef))
		var select = getDocElm(formId_or_formRef, fieldId_or_fieldIndex);
	else  var select = formId_or_formRef.elements[fieldId_or_fieldIndex];
	var selectLength = select.length;
	fieldValue = "" + fieldValue + ""; // turn int to string
	var success_foundValue = false;
	for(var i = 0; i < selectLength; i++) {
		if(select[i].value == fieldValue) {
			success_foundValue = true;  select.selectedIndex = i;  break;
		}
	}
	return success_foundValue;
}


/*str*/ function form_getFieldType(/*str|ref*/formId_or_formRef, /*str|int*/fieldId_or_fieldIndex) {
	//	field type for buttons etc. is returned as "irrelevant"
	var field;
	if(isString(formId_or_formRef))  field = getDocElm(formId_or_formRef, fieldId_or_fieldIndex);
	else  field = formId_or_formRef.elements[fieldId_or_fieldIndex];
	var tagType = field.tagName.toLowerCase();  var fieldType;
	switch(tagType) {
		case "input":
			fieldType = field.getAttribute("type").toLowerCase();
			switch(fieldType) {
				case "text":  case "password":  case "hidden":  case "file":
				case "checkbox":  case "radio":
					return fieldType;
				default: // submit, reset, image, etc.
					return "irrelevant";
			}
			break;
		case "textarea":  case "select":
			return tagType;
		default:  // button etc.
			return "irrelevant";
	}
	return "";
}


/*arr/null*/ function form_getFields_nameValue(formId_or_formRef) {
	if(isString(formId_or_formRef))  var form = getDocElm(formId_or_formRef);
	else  var form = formId_or_formRef;
    var key_nameValue = new Array();
    //  iterate form elements ----------------------------------------
    var fieldKey = -1;  var element;  var tagType;  var fieldType;  var fieldName;  var fieldValue;
    var formLength = form.elements.length;
    for(var i = 0; i < formLength; i++) {
        element = form.elements[i];
        fieldName = element.name;  fieldValue = "";
        //  establish field type -----------------
        tagType = element.tagName.toLowerCase();
        switch(tagType) {
            case "input":
                fieldType = element.getAttribute("type").toLowerCase();
                switch(fieldType) {
                    case "text":  case "password":  case "hidden":  case "file":
                    case "checkbox":  case "radio":
                        break; // nada
                    default: // submit, reset, image, etc.
                        continue; // skip
                }
                break;
            case "textarea":  case "select":
                fieldType = tagType;
                break;
            default:  // button etc.
                continue; // skip
        }
        //  find value ---------------------------
        switch(fieldType) {
            case "text":  case "password":  case "textarea":  case "hidden":  case "file":
                fieldValue = element.value;
                break;
            case "checkbox":  case "radio":
                if(element.checked == true)  fieldValue = element.value;
                else  continue; // skip
                break;
            case "select":
                if(element.selectedIndex !== undefined)  fieldValue = element[element.selectedIndex].value;
                break;
            default:  continue; // skip
        }
        //  add to array -------------------------
        key_nameValue[++fieldKey] = new Array(2);
        key_nameValue[fieldKey][0] = fieldName;  key_nameValue[fieldKey][1] = fieldValue;
    }
    //  check if array has buckets (dont want to return an empty array, null is better)
	if(key_nameValue.length > 0)  return key_nameValue;
	else  return null;
}



/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*//*                                          simple-complex tinySimple CMS v. 0.9.60 - www.tinysimple.net
*       javascriptXdomCss
####### DISTRIBUTED UNDER THE LGPL LICENSE ###################################################################
# The library javascriptXcss delivers javascript x DOM/css functions.
# This library was originally created as part of the program simple-complex tinySimple CMS v. 0.9.60
####### Copyright (C) 2007-2009 Jacob Friis Mathiasen ########################################################
# This library is free software; you can redistribute it and/or modify it under the terms of the
# GNU Lesser General Public License as published by the Free Software Foundation;
# either version 3 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with this library;
# if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA (or check http://www.gnu.org/licenses/lgpl.html).
# Copyright holder contact info:
# Email: dev.simplecomplex@gmail.com. Paper mail: Jacob Friis Mathiasen, Sk 38, DK-1709 V, Copenhagen, Denmark
############################################################################################################*/
/*///// javascriptXcss /////////////////////////////////////////////////////////////////////////////////////*/

//  browser error fixes --------------------------------------------------------------------------------------
var UAFIX_displayTable = "table";
var UAFIX_displayTableCell = "table-cell";
if(USERAGENT == "ie") {
    UAFIX_displayTable = "block";  UAFIX_displayTableCell = "block";
}

//  cross-brwser event listeners ---------------------------------------------------------------------------
var eventListenerReg = new eventListenerRegistry();
/*void*/ function addRegEventListener(/*str|arr*/ identifier, eventName, functionName) {
    if(typeof identifier == "string" || identifier instanceof Array == true)
        eventListenerReg.addEventListener(identifier, eventName, functionName);
    else  alert("addRegisteredEventListener: identifier for the element to register the event "
           + eventName + " on is not string or array , thus the event listener cannot be registered");
}
/*void*/ function addUnregEventListener(/*str|arr|ref*/ identifier_or_ref, eventName, functionName) {
    eventListenerReg.addEventListener(identifier_or_ref, eventName, functionName);
}

/*void*/ function removeRegEventListener(/*str|arr*/ identifier, eventName, functionName) {
    if(typeof identifier == "string" || identifier instanceof Array == true)
        eventListenerReg.removeEventListener(identifier, eventName, functionName);
    else  alert("removeRegisteredEventListener: identifier for the element to identify the event "
        + eventName + " by is not string or array, thus the event listener cannot be removed from registry");
}
/*void*/ function removeUnregListener(/*str|arr|ref*/ identifier_or_ref, eventName, functionName) {
    eventListenerReg.removeEventListener(identifier_or_ref, eventName, functionName);
}

/*void*/ function removeAllRegEventListeners(/*str|arr*/ identifier, /*optional:str*/ eventName) {
    if(typeof identifier == "string" || identifier instanceof Array == true)
        eventListenerReg.removeAllEventListeners(identifier, eventName);
    else  alert("removeRegisteredEventListener: identifier for the element"
           + " is not string or array, thus the event listeners cannot be removed");
}

/*object*/ function eventListenerRegistry() {        
    var _reg_elmEventFunc = new Array();
    
    /*private void*/ function addEventListener_standard(docElm, eventName, functionName) {
        docElm.addEventListener(eventName, functionName, false);
    }
    /*private void*/ function addEventListener_ie(docElm, eventName, functionName) {
        try {  docElm.attachEvent("on" + eventName, functionName);  }
        catch(needStandard_error) {  docElm.addEventListener(eventName, functionName, false);  }
    }    
    /*private void*/ function removeEventListener_standard(docElm, eventName, functionName) {
        docElm.removeEventListener(eventName, functionName, false);
    }
    /*private void*/ function removeEventListener_ie(docElm, eventName, functionName) {
        try {  docElm.detachEvent("on" + eventName, functionName);  }
        catch(needStandard_error) {  docElm.removeEventListener(eventName, functionName, false);  }
    }
    
    /*void*/ this.removeAllEventListeners = function(/*str|arr*/ identifier, /*optional:str*/ eventName) {
        var regIdentifier;
        if(typeof identifier == "string") {
            regIdentifier = identifier;
            docElm = getDocElm(identifier);
        }  
        else {
            regIdentifier = "" + identifier[0] + "|" + identifier[1] + "";
            docElm = getDocElm( identifier[0] , identifier[1] );
        }            
        if(_reg_elmEventFunc[regIdentifier] !== undefined
        && _reg_elmEventFunc[regIdentifier] != null) {
            if(eventName !== undefined && typeof eventName == "string") {
                //  go only for that particular event ----------------
                if(_reg_elmEventFunc[regIdentifier][eventName] !== undefined
                && _reg_elmEventFunc[regIdentifier][eventName] != null) {
                    var function_name;
                    for(var index = 0; index < _reg_elmEventFunc[regIdentifier][eventName].length; index++) {
                    	if( (function_name = _reg_elmEventFunc[regIdentifier][eventName][index]) != null) 
                    	    this.removeEventListener_byUseragent(docElm, eventName, function_name);
                    }
                    _reg_elmEventFunc[regIdentifier][eventName] = null; // clear registry
                    return;
                }
                else  return; // none registered for that event
            }
            else { // go for all event types set on this element
                var function_name;
                for(var event_name in _reg_elmEventFunc[regIdentifier]) { 
                    for(var index = 0; index < _reg_elmEventFunc[regIdentifier][event_name].length; index++){
                    	if( (function_name = _reg_elmEventFunc[regIdentifier][event_name][index]) != null)
                    	    this.removeEventListener_byUseragent(docElm, event_name, function_name);
                    }
                }
                _reg_elmEventFunc[regIdentifier] = null; // clear registry
                return;
            }            
        }
        // else, nothing registered for this element
    };
    
    /*void*/ this.addEventListener = function(/*str|arr|ref*/ identifier_or_ref, eventName, functionName) {
        var isArray = false;  var docElm;
        if(typeof identifier_or_ref == "string" || (isArray = identifier_or_ref instanceof Array) == true) {
            var regIdentifier;  var index = 0;
            if(isArray == false) {
                regIdentifier = identifier_or_ref;
                if(identifier_or_ref == "document")  docElm = document;
                else  docElm = getDocElm(identifier_or_ref);
            }  
            else {
                regIdentifier = "" + identifier_or_ref[0] + "|" + identifier_or_ref[1] + "";
                docElm = getDocElm( identifier_or_ref[0] , identifier_or_ref[1] );
            }
            if(_reg_elmEventFunc[regIdentifier] !== undefined
            && _reg_elmEventFunc[regIdentifier] != null) { }
            else  _reg_elmEventFunc[regIdentifier] = new Array();
            if(_reg_elmEventFunc[regIdentifier][eventName] !== undefined
            && _reg_elmEventFunc[regIdentifier][eventName] != null)  
                index = _reg_elmEventFunc[regIdentifier][eventName].length;
            else  _reg_elmEventFunc[regIdentifier][eventName] = new Array();
            _reg_elmEventFunc[regIdentifier][eventName][index] = functionName;            
            
        }
        else  docElm = identifier_or_ref;
        this.addEventListener_byUseragent(docElm, eventName, functionName);
    };
    
    /*void*/ this.removeEventListener = function(/*str|arr|ref*/ identifier_or_ref, eventName, functionName) {
        var isArray = false;  var docElm;
        if(typeof identifier_or_ref == "string" || (isArray = identifier_or_ref instanceof Array) == true) {
            var regIdentifier; 
            if(isArray == false) {
                regIdentifier = identifier_or_ref;
                if(identifier_or_ref == "document")  docElm = document;
                else  docElm = getDocElm(identifier_or_ref);
            }  
            else {
                regIdentifier = "" + identifier_or_ref[0] + "|" + identifier_or_ref[1] + "";
                docElm = getDocElm( identifier_or_ref[0] , identifier_or_ref[1] );
            }
            if(_reg_elmEventFunc[regIdentifier] !== undefined
            && _reg_elmEventFunc[regIdentifier][eventName] !== undefined
            && _reg_elmEventFunc[regIdentifier][eventName] != null) {
                var function_name;
                for(var index = 0; index < _reg_elmEventFunc[regIdentifier][eventName].length; index++) {
                    if( (function_name = _reg_elmEventFunc[regIdentifier][eventName][index]) != null
                    && function_name == functionName)
                    	_reg_elmEventFunc[regIdentifier][eventName][index] = null;
                }
            }
            else  return;
        }
        else  docElm = identifier_or_ref;
        this.removeEventListener_byUseragent(docElm, eventName, functionName);
    };
    
    if(USERAGENT == "ie") {
        this.addEventListener_byUseragent = addEventListener_ie;
        this.removeEventListener_byUseragent = removeEventListener_ie;
    }
    else {
        this.addEventListener_byUseragent = addEventListener_standard;
        this.removeEventListener_byUseragent = removeEventListener_standard;
    }
}

/*ref|null*/ function getEventTriggerElement(e) {
    var windowEvent;  if(e !== undefined) windowEvent = e;  else windowEvent = window.event;
    var elmRef;
    switch(USERAGENT) {
    	case "ie":
    		if(windowEvent.srcElement !== undefined)  elmRef = windowEvent.srcElement;
    		else if(windowEvent.target !== undefined)  elmRef = windowEvent.target;
    		return elmRef;
    	case "safari":
    		if(windowEvent.target !== undefined)  elmRef = windowEvent.target;
    		if(elmRef.nodeType == 3)  elmRef = elmRef.parentNode; // Safari bug
    		return elmRef;
    	default: // varValueOthers
    	    if(windowEvent.target !== undefined)  elmRef = windowEvent.target;
    	    return elmRef;
    }
}


//  mouse position -------------------------------------------------------------------------------------------
var mousePosition = USERAGENT === "ie" ? function() {
        return [globals["mouseHori"] = window.event.clientX, globals["mouseVert"] = window.event.clientY]; } :
        function(e) {
        return [globals["mouseHori"] = e.clientX, globals["mouseVert"] = e.clientY]; };
//  register
addRegEventListener("document", "mousemove", mousePosition);

//	browser dimensions ---------------------------------------------------------------------------------------
globals["browserWidth"] = 0;  globals["browserHeight"] = 0;
globals["bodyWidth"] = 0; /*=*/ globals["documentWidth"] = 0; // synonymous  
globals["bodyHeight"] = 0; /*=*/ globals["documentHeight"] = 0; // synonymous 
globals["allWidth"] = 0;  globals["allHeight"] = 0; // largest value of the above
function browserDimensions() {
    //  browser ------------------------------------------------------
    var browserWidth, browserHeight;
    if(document.documentElement.clientWidth && document.documentElement.clientWidth > 0)
        //  gecko does fortunately _not_ include scrollbar width in document.documentElement.clientWidth
        browserWidth = document.documentElement.clientWidth;  
    else if(typeof(window.innerWidth) == "number") {
		//  fix: gecko includes scrollbar width in innerWidth
		if(document.body.offsetWidth !== undefined
        && document.body.offsetWidth > 0  // gecko<1.5 knows this value, but sets it to zero (that wont do)
        && window.innerWidth > document.body.offsetWidth)  browserWidth = document.body.offsetWidth;
        else  browserWidth = window.innerWidth;
    }
    else  browserWidth = document.body.clientWidth;
	if(document.documentElement.clientHeight && document.documentElement.clientHeight > 0)
	    browserHeight = document.documentElement.clientHeight;
    else if(typeof(window.innerHeight) == "number") {
		//  fix: gecko includes scrollbar width in innerHeight
		if(document.body.offsetHeight !== undefined
        && document.body.offsetHeight > 0  // gecko<1.5 knows this value, but sets it to zero (that wont do)
        && window.innerHeight > document.body.offsetHeight)  browserHeight = document.body.offsetHeight;
        else  browserHeight = window.innerHeight;
    }
    else if(document.documentElement.clientHeight)  browserHeight = document.documentElement.clientHeight;
    else  browserHeight = document.body.clientHeight;    
    globals["browserWidth"] = browserWidth;  globals["browserHeight"] = browserHeight;  //  set globals
    //  body|document ------------------------------------------------
    var bodyWidth, bodyHeight;
    var documentElement_scrollWidth, documentElement_scrollHeight, body_scrollWidth, body_scrollHeight;
    if( (documentElement_scrollWidth = document.documentElement.scrollWidth)
    > (body_scrollWidth = document.body.scrollWidth) )  bodyWidth = documentElement_scrollWidth;
    else  bodyWidth = body_scrollWidth;
    if( (documentElement_scrollHeight = document.documentElement.scrollHeight)
    > (body_scrollHeight = document.body.scrollHeight) )  bodyHeight = documentElement_scrollHeight;
    else  bodyHeight = body_scrollHeight;
    globals["bodyWidth"] = bodyWidth; /*=*/ globals["documentWidth"] = bodyWidth;
    globals["bodyHeight"] = bodyHeight; /*=*/ globals["documentHeight"] = bodyHeight;
    //  largest value ------------------------------------------------    
    if(bodyWidth > browserWidth)  globals["allWidth"] = bodyWidth;
    else  globals["allWidth"] = browserWidth;
    if( (globals["allHeight_browserHeightRules"] !== undefined
            && globals["allHeight_browserHeightRules"] == 1)
    || bodyHeight < browserHeight)  globals["allHeight"] = browserHeight;
    else  globals["allHeight"] = bodyHeight;      
    /*alert("browserHeight:" + browserHeight
            + " document.documentElement.scrollHeight:"+document.documentElement.scrollHeight
            + " document.body.scrollHeight:" + document.body.scrollHeight
            + " globals[\"allHeight\"]:" + globals["allHeight"] + "");*/
}

//	scroll ---------------------------------------------------------------------------------------------------
function scrollPosition() {
	var scrollPositionLeft;  var scrollPositionTop;
	if(self.pageYOffset) { // standards compliant browsers
		scrollPositionLeft = self.pageXOffset;
		scrollPositionTop = self.pageYOffset;
	}
	else if(document.documentElement && document.documentElement.scrollTop) { // ie strict
		scrollPositionLeft = document.documentElement.scrollLeft;
		scrollPositionTop = document.documentElement.scrollTop;
	}
	else { // all other ie s
		try {  scrollPositionLeft = document.body.scrollLeft;  scrollPositionTop = document.body.scrollTop;  }
		catch(error) {  scrollPositionLeft = 0;  scrollPositionTop = 0;  }
	}		
    globals["scrollLeft"] = scrollPositionLeft;
    globals["scrollTop"] = scrollPositionTop;
}

function scroll_to(fromTop) {
	scrollPosition();
	window.scrollTo(globals["scrollLeft"], fromTop);
}

function scroll_by(add2Top) {
	scrollPosition();
	window.scrollTo(globals["scrollLeft"], globals["scrollTop"] + add2Top);
}

//  styleInspector -------------------------------------------------------------------------------------------
//  object that delivers style information according to current browser
//  use simple function or styleInspector methods directly
//  getStyle | styleInspectorObj.getStyle
//  isVisible | styleInspectorObj.isVisible
/*object*/ function styleInspector() {    
//  dont go for style[x] or style.x (which is the same)
//  - they only tell about styles defined inline and styles set via javascript
//  - they dont tell about styles defined by sheet (or defined in html head)

    //  get style ------------------------------------------------------------------------    
    /*private str|null*/ function getStyleString_standard(docElm, styleName) {
        var styleValue = null; 
        if( (styleValue = document.defaultView.getComputedStyle(docElm,"").getPropertyValue( styleName ))
        !== undefined)  return styleValue;
        return null;
    }    
    /*private str|null*/ function getStyleString_ie(docElm, styleName) {
        var styleValue = null; 
        //  make converted version of style name (font-size -> fontSize)
        var styleNameConverted = styleName;
        if(styleName.indexOf("-") != -1) {
            var exploded = styleName.split("-");
            styleNameConverted = exploded[0];
            for(var i = 1; i < exploded.length; i++)
                styleNameConverted += exploded[ i ].substr(0, 1).toUpperCase() + exploded[ i ].substr(1);
        }
        if( (styleValue = docElm.currentStyle[ styleNameConverted ]) !== undefined)  return styleValue;
        return null;
    }    
    /*str|int|null*/ this.getStyle = function(identifier_or_ref, styleName, /*optional:bool*/ returnInteger) {
        if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
        else  var docElm = identifier_or_ref;
        if(docElm == null)  return null;
        var styleValue = this.getStyleString(docElm, styleName);
        //  return integer, stripped for letters?
        if(styleValue !== null && returnInteger !== undefined && returnInteger == true) {
            styleValue = parseInt( styleValue.replace(/[A-Za-z]/, "") , 10);
            if(isNaN(styleValue))  return 0;
            else  return styleValue;
        }
        return styleValue;
    };    
    //  effective width|height (xhtml: effective height = height + padding + border)
    /*str|int|null*/ this.getEffectiveDimension = function(identifier_or_ref, styleName, returnInteger){
        if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
        else  var docElm = identifier_or_ref;        
        if(styleName == "width") {  var baseProp = "width";  var side_0 = "left";  var side_1 = "right";  }
        else {  var baseProp = "height";  var side_0 = "top";  var side_1 = "bottom";  }           
        var cumulateStyleValue = null;  var styleValue = null;
        if( (styleValue = this.getStyle(docElm, baseProp, true)) != null)
            cumulateStyleValue = styleValue;
        styleValue = null;
        if( (styleValue = this.getStyle(docElm, "padding-" + side_0, true)) != null) {
            if(cumulateStyleValue != null)  cumulateStyleValue += styleValue;
            else  cumulateStyleValue = styleValue;
        }
        styleValue = null;
        if( (styleValue = this.getStyle(docElm, "padding-" + side_1, true)) != null) {
            if(cumulateStyleValue != null)  cumulateStyleValue += styleValue;
            else  cumulateStyleValue = styleValue;
        }
        styleValue = null;
        if( (styleValue = this.getStyle(docElm, "border-" + side_0 + "-width", true)) != null) {
            if(cumulateStyleValue != null)  cumulateStyleValue += styleValue;
            else  cumulateStyleValue = styleValue;
        }
        styleValue = null;
        if( (styleValue = this.getStyle(docElm, "border-" + side_1 + "-width", true)) != null) {
            if(cumulateStyleValue != null)  cumulateStyleValue += styleValue;
            else  cumulateStyleValue = styleValue;
        }
        if(cumulateStyleValue != null && !returnInteger)  cumulateStyleValue = "" + cumulateStyleValue + "px";
        return cumulateStyleValue;
    };
    
    //  is visible? ----------------------------------------------------------------------    
    /*private bool*/ function isVisible_standard(docElm) {
        while(true) {
            if(document.defaultView.getComputedStyle(docElm,"").getPropertyValue("display") == "none"
            || document.defaultView.getComputedStyle(docElm,"").getPropertyValue("visibility") == "hidden")
                return false;
            if(docElm.nodeName.toLowerCase() == 'body')  break;
            docElm = docElm.parentNode;
        }
        return true;
    }
    /*private bool*/ function isVisible_ie(docElm) {
        while(true) {
            if(docElm.currentStyle["display"] == "none"
            || docElm.currentStyle["visibility"] == "hidden")
                return false;
            if(docElm.nodeName.toLowerCase() == 'body')  break;
            docElm = docElm.parentNode;
        }
        return true;
    } 
    /*bool*/ this.isVisible = function(identifier_or_ref, fieldId) {
        if(typeof identifier_or_ref == "string") {
            if(fieldId !== undefined)  var docElm = getDocElm(identifier_or_ref, fieldId);
            else  var docElm = getDocElm(identifier_or_ref);
        }
        else  var docElm = identifier_or_ref;
        if(docElm == null)  return false;
        return this.isVisible_byScheme(docElm);
    };
    
    //  constructor ----------------------------------------------------------------------
    if(USERAGENT == "ie") {
        this.getStyleString = getStyleString_ie;
        this.isVisible_byScheme = isVisible_ie;
    }
    else {
        this.getStyleString = getStyleString_standard;
        this.isVisible_byScheme = isVisible_standard;
    }
}
var styleInspectorObj = new styleInspector();
/*str|int|null*/ function getStyle(identifier_or_ref, styleName, /*optional:bool*/ returnInteger) {
    return styleInspectorObj.getStyle(identifier_or_ref, styleName, returnInteger);
}
/*bool*/ function isVisible(identifier_or_ref, fieldId) {
    return styleInspectorObj.isVisible(identifier_or_ref, fieldId);
}
//  get effective style, currently only supports width and height
/*str|int|null*/ function getEffectiveStyle(identifier_or_ref, styleName, /*optional:bool*/ returnInteger) {
    return styleInspectorObj.getEffectiveDimension(identifier_or_ref, styleName, returnInteger);
}
/*str|int|null*/ function getStyle_effectiveWidth(identifier_or_ref, /*optional:bool*/ returnInteger) {
    return styleInspectorObj.getEffectiveDimension(identifier_or_ref, "width", returnInteger);
}
/*str|int|null*/ function getStyle_effectiveHeight(identifier_or_ref, /*optional:bool*/ returnInteger) {
    return styleInspectorObj.getEffectiveDimension(identifier_or_ref, "height", returnInteger);
}
/*void*/ function setStyle_effectiveWidth(identifier_or_ref, newWidth) {
    if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
    else  var docElm = identifier_or_ref;
    if(docElm == null)  return;
    var width_padding_border = styleInspectorObj.getEffectiveDimension(docElm, "width", 1);
    if(width_padding_border == null)  return;
    var widthAlone = styleInspectorObj.getStyle(docElm, "width", 1);
    docElm.style.width = "" + (newWidth - (width_padding_border - widthAlone)) + "px";
}
/*void*/ function setStyle_effectiveHeight(identifier_or_ref, newHeight) {
    if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
    else  var docElm = identifier_or_ref;
    if(docElm == null)  return;
    var height_padding_border = styleInspectorObj.getEffectiveDimension(docElm, "height", 1);
    if(height_padding_border == null)  return;
    var heightAlone = styleInspectorObj.getStyle(docElm, "height", 1);
    docElm.style.height = "" + (newHeight - (height_padding_border - heightAlone)) + "px";
}


//  checked focus() ------------------------------------------------------------------------------------------
//  delays focus() and checks if element is actually visible 
//  use simple function focusChecked()
var checked_focus_object_ref;
/*void*/ function focusChecked(identifier_or_ref, fieldId) {
    if(checked_focus_object_ref == null)  checked_focus_object_ref = new checked_focus_object();
    checked_focus_object_ref.orderFocus(identifier_or_ref, fieldId);
}
/*class*/ function checked_focus_object() {
    var _docElm;  var _focusTimer;        
    /*bool*/ this.orderFocus = function(identifier_or_ref, fieldId) {
        if(typeof identifier_or_ref == "string") {
            if(fieldId != null)  _docElm = getDocElm(identifier_or_ref, fieldId);
            else  _docElm = getDocElm(identifier_or_ref);
        }
        else {
            if(fieldId != null)  _docElm = identifier_or_ref.elements[fieldId];
            else  _docElm = identifier_or_ref;
        }
        if(_docElm !== undefined) { 
            _focusTimer = setTimeout("checked_focus_object_ref.setFocus()", 10); 
	        return true;
        }
	    else  return false;
    };        
    /*void*/ this.setFocus = function() {
        if(_docElm !== undefined && _docElm != null && isVisible(_docElm))  _docElm.focus();
    };
}

//  positioning ----------------------------------------------------------------------------------------------

/*class*/ function position(identifier_or_ref, method, args) {
    
    
    
/*void*/ function positionObject_ignoreStoredPosition(identifier_or_ref, hori, vert,
      /*optionals*/ horiModifier, vertModifer, preferFixedPositioning) {
    positionObject(identifier_or_ref, hori, vert,
            horiModifier, vertModifer, preferFixedPositioning, true) 
}
//  identifier_or_ref (the object to be positioned) must be a div (because uses visibility, not display)
/*void*/ function positionObject(identifier_or_ref, hori, vert,
      /*optionals*/ horiModifier, vertModifer, preferFixedPositioning, ignoreStoredPosition) {
    var docElm;
    if(identifier_or_ref !== undefined) {
        if(typeof identifier_or_ref == "string")  docElm = getDocElm(identifier_or_ref);
        else  docElm = identifier_or_ref;
        if(docElm !== undefined && docElm != null) {}
        else  return;
    }
    else  return;
    //  if element has height 0px, we cannot determine offsetHeight, thus (if hidden) set height to auto
    var setHeightToZero = false;
    if(docElm.style.visibility == "hidden" && docElm.style.height == "0px") {
        docElm.style.height = "auto";  setHeightToZero = true;
    }
    browserDimensions();  var fromLeft, fromTop = 0;
    switch(hori) {
        case "left":  break;
        case "right":  fromLeft = globals["browserWidth"] - docElm.offsetWidth;  break;
        default: // center
            if( (fromLeft = Math.floor((globals["browserWidth"] - docElm.offsetWidth) / 2)) < 0)
                fromLeft = 0;
    }
    switch(vert) {
        case "top":  break;
        case "bottom":  fromTop = globals["browserHeight"] - docElm.offsetHeight;  break;
        default: // middle
            if( (fromTop = Math.floor((globals["browserHeight"] - docElm.offsetHeight) / 2)) < 0)
               fromTop = 0;
    }
    if(horiModifier !== undefined && isNumber(horiModifier))  fromLeft += horiModifier;
    if(vertModifer !== undefined && isNumber(vertModifer))  fromTop += vertModifer;
    docElm.style.left = "" + fromLeft + "px";
    docElm.style.top = "" + fromTop + "px";
    if( (preferFixedPositioning !== undefined && preferFixedPositioning == true)
    || globals["browserHeight"] < docElm.offsetHeight)
        docElm.style.position = "absolute";
    else  docElm.style.position = "fixed";   
    //  set height back to zero?
    if(setHeightToZero == true)  docElm.style.height = "0px";
    //  cookie stored coords for movable object? -----------------------------------------
    if(ignoreStoredPosition !== undefined && ignoreStoredPosition == true)  return;
    //  we have to do this so late, to ensure check for positioning fixed/absolute    
    if(typeof identifier_or_ref == "string") { 
        var endPosition;
        if( (endPosition = readCookie("movableElement_endPosition__" + identifier_or_ref)) !== null
        && endPosition.length > 1) {
            var endPositionArr = endPosition.split("_");
            //  check that browser size is precisely the same as in last page load
            if(parseInt(endPositionArr[0],10) != globals["browserWidth"]
            || parseInt(endPositionArr[1],10) != globals["browserHeight"])  return;
            docElm.style.left = "" + parseInt(endPositionArr[2],10) + "px";
            docElm.style.top = "" + parseInt(endPositionArr[3],10) + "px";
        }
        var minMax_params;
        if( (minMax_params = readCookie("minMax__" + identifier_or_ref)) != null && minMax_params != "1") {
            var minMaxArr = minMax_params.split("__");  var minMaxLength = minMax_params.length;
            for(var k = 1; k < minMaxLength; k++) {
                // strings must be marked contrary to numbers, already in minMaximize...
            }
            var positionFunction = minMaxArr[0];
        }
    }
}    
    
    
    
    
    
}

//	position element -----------------------------------------------------------------------------------------
//  NB: minMaximize() depends on these functions parameter sequence
//  identifier_or_ref (the object to be positioned) must be a div (because uses visibility, not display)
/*void*/ function positionObject_ignoreStoredPosition(identifier_or_ref, hori, vert,
      /*optionals*/ horiModifier, vertModifer, preferFixedPositioning) {
    positionObject(identifier_or_ref, hori, vert,
            horiModifier, vertModifer, preferFixedPositioning, true) 
}
//  identifier_or_ref (the object to be positioned) must be a div (because uses visibility, not display)
/*void*/ function positionObject(identifier_or_ref, hori, vert,
      /*optionals*/ horiModifier, vertModifer, preferFixedPositioning, ignoreStoredPosition) {
    var docElm;
    if(identifier_or_ref !== undefined) {
        if(typeof identifier_or_ref == "string")  docElm = getDocElm(identifier_or_ref);
        else  docElm = identifier_or_ref;
        if(docElm !== undefined && docElm != null) {}
        else  return;
    }
    else  return;
    //  if element has height 0px, we cannot determine offsetHeight, thus (if hidden) set height to auto
    var setHeightToZero = false;
    if(docElm.style.visibility == "hidden" && docElm.style.height == "0px") {
        docElm.style.height = "auto";  setHeightToZero = true;
    }
	browserDimensions();  var fromLeft = 0, fromTop = 0;
	switch(hori) {
		case "left":  break;
		case "right":  fromLeft = globals["browserWidth"] - docElm.offsetWidth;  break;
		default: // center
			if( (fromLeft = Math.floor((globals["browserWidth"] - docElm.offsetWidth) / 2)) < 0)
			    fromLeft = 0;
	}
	switch(vert) {
		case "top":  break;
		case "bottom":  fromTop = globals["browserHeight"] - docElm.offsetHeight;  break;
		default: // middle
			if( (fromTop = Math.floor((globals["browserHeight"] - docElm.offsetHeight) / 2)) < 0)
			   fromTop = 0;
	}
	if(horiModifier !== undefined && isNumber(horiModifier))  fromLeft += horiModifier;
	if(vertModifer !== undefined && isNumber(vertModifer))  fromTop += vertModifer;	
    docElm.style.left = "" + fromLeft + "px";
    docElm.style.top = "" + fromTop + "px";
    if( (preferFixedPositioning !== undefined && preferFixedPositioning == true)
    || globals["browserHeight"] < docElm.offsetHeight)
        docElm.style.position = "absolute";
    else  docElm.style.position = "fixed";   
    //  set height back to zero?
    if(setHeightToZero == true)  docElm.style.height = "0px";
    //  cookie stored coords for movable object? -----------------------------------------
    if(ignoreStoredPosition !== undefined && ignoreStoredPosition == true)  return;
    //  we have to do this so late, to ensure check for positioning fixed/absolute    
	if(typeof identifier_or_ref == "string") { 
	    var endPosition;
    	if( (endPosition = readCookie("movableElement_endPosition__" + identifier_or_ref)) !== null
    	&& endPosition.length > 1) {
    	    var endPositionArr = endPosition.split("_");
    	    //  check that browser size is precisely the same as in last page load
    	    if(parseInt(endPositionArr[0],10) != globals["browserWidth"]
    	    || parseInt(endPositionArr[1],10) != globals["browserHeight"])  return;
    	    docElm.style.left = "" + parseInt(endPositionArr[2],10) + "px";
    	    docElm.style.top = "" + parseInt(endPositionArr[3],10) + "px";
    	}
    	var minMax_params;
    	if( (minMax_params = readCookie("minMax__" + identifier_or_ref)) != null && minMax_params != "1") {
    	    var minMaxArr = minMax_params.split("__");  var minMaxLength = minMax_params.length;
    	    for(var k = 1; k < minMaxLength; k++) {
    	    	// strings must be marked contrary to numbers, already in minMaximize...
    	    }
    	    var positionFunction = minMaxArr[0];
    	}
	}
}

//  does _not_ calculate object dimensions (and cannot memorize position) ----------------
//  always prefers to set object right/below point
//  and prefers setting mouse_marginToPoint horizontally +, and vertically - (which means its use twice)
/*void*/ function positionByCoords_dimensionsKnown(identifier_or_ref,/*int*/width, height, coordLeft,coordTop, 
      /*optionals*/ mouse_marginToPoint, allowPartiallyHidden, preferFixedPositioning) {
    var docElm;
    if(identifier_or_ref !== undefined) {
        if(typeof identifier_or_ref == "string")  docElm = getDocElm(identifier_or_ref);
        else  docElm = identifier_or_ref;
        if(docElm !== undefined && docElm != null) {}   else  return;
    }
    else  return;
    browserDimensions();  
    var browserWidth = globals["browserWidth"];  var browserHeight = globals["browserHeight"];
    var fromLeft, fromTop, minToBrowserEdge, marginToPoint, allowOverflow, overflowDetected = 0;
    if(globals["minToBrowserEdge"] !== undefined 
    && (minToBrowserEdge = globals["minToBrowserEdge"]) > 0) { }
    else  minToBrowserEdge = 0;
    if(mouse_marginToPoint !== undefined && (marginToPoint = mouse_marginToPoint) > 0) { }
    else  marginToPoint = 0;
    if(allowPartiallyHidden !== undefined && allowPartiallyHidden == 1)  allowOverflow = 1;
    var horiMarginSecured = false;
    //  establish left -----------------------------------------------
    //  try on the right side of point
    if(coordLeft + marginToPoint + width + minToBrowserEdge <= browserWidth  // no problem
    || allowOverflow == 1) { // problem, but allowed
        fromLeft = coordLeft + marginToPoint;  horiMarginSecured = true;
    } 
    else {
        //  still on the right side, but skip min-to-browser-edge
        if(coordLeft + marginToPoint + width <= browserWidth) {
            fromLeft = coordLeft + marginToPoint;  horiMarginSecured = true;  }
        //  try instead on the left side
        else if(minToBrowserEdge + width + marginToPoint <= coordLeft) { 
            fromLeft = coordLeft - (minToBrowserEdge + width + marginToPoint);  horiMarginSecured = true; }
        //  still on the left side, but skip min-to-browser-edge
        else if(width + marginToPoint <= coordLeft) {
            fromLeft = coordLeft - (width + marginToPoint);  horiMarginSecured = true;  }
        //  so wide it will hide point in the horizontal dimension, no matter what
        else if(width > browserWidth) {  fromLeft = minToBrowserEdge;  overflowDetected = 1;  }
        else if(minToBrowserEdge + width >= browserWidth)  fromLeft = 0;
        //  it will hide point in the horizontal dimension,
        //  but worthwhile checking whether left or right side of point is the better
        else { 
            if(coordLeft <= Math.floor(browserWidth / 2))  
                fromLeft = browserWidth - (width + minToBrowserEdge); // put it on the right side 
            else  fromLeft = minToBrowserEdge; // on the left side
        }
    } 
    //  establish top ------------------------------------------------
    //  if horizontal margin is secured, we want place vertically slightly above the point (thus negative)
    if(horiMarginSecured == true)  marginToPoint = -marginToPoint;
    //  try generally below
    if(coordTop + marginToPoint + height + minToBrowserEdge <= browserHeight  // no problem
    || allowOverflow == 1) // problem, but allowed
        fromTop = coordTop + marginToPoint;
    else { horiMarginSecured = false; marginToPoint = -marginToPoint;
        //  still below, but skip min-to-browser-edge
        if(coordTop + marginToPoint + height <= browserHeight) {
            fromTop = coordTop + marginToPoint;  }
        //  try partially above
        else if(horiMarginSecured == true && minToBrowserEdge + height <= browserHeight) { 
            fromTop = browserHeight - (minToBrowserEdge + height);  }  
        //  try all above 
        else if(horiMarginSecured == false && minToBrowserEdge + height + marginToPoint <= coordTop) { 
            fromTop = coordTop - (minToBrowserEdge + height + marginToPoint);  } 
        //  so tall it might hide point in the vertical dimension, no matter what  
        else if(minToBrowserEdge + height <= browserHeight) { // all over the place
            fromTop = browserHeight - (minToBrowserEdge + height);  }
        else if(height <= browserHeight) { // all over the place, but skip min-to-browser-edge
            fromTop = browserHeight - height;  }
        else { 
            fromTop = 0;
        }
    }  
    docElm.style.left = "" + fromLeft + "px";  docElm.style.top = "" + fromTop + "px";
    if( (preferFixedPositioning !== undefined && preferFixedPositioning == true)
    || overflowDetected == 1)  docElm.style.position = "absolute";
    else  docElm.style.position = "fixed";   
}

//  supports relative centered position (example: 1/3 from top)
//  NB: minMaximize() depends on these functions parameter sequence
//  identifier_or_ref (the object to be positioned) must be a div (because uses visibility, not display)
/*void*/ function centerObject_ignoreStoredPosition(identifier_or_ref, hori_vert,
		/*optionals*/ relationLeft, relationTop, minLeft, minTop, prefer_minLeft, prefer_minTop) {
    centerObject(identifier_or_ref, hori_vert,
		relationLeft, relationTop, minLeft, minTop, prefer_minLeft, prefer_minTop, true)
}
//  identifier_or_ref (the object to be positioned) must be a div (because uses visibility, not display)
/*void*/ function centerObject(identifier_or_ref, hori_vert,
		/*optionals*/ relationLeft, relationTop, minLeft, minTop, prefer_minLeft, prefer_minTop,
		ignoreStoredPosition) {
	var docElm;
    if(identifier_or_ref !== undefined) {
        if(typeof identifier_or_ref == "string")  docElm = getDocElm(identifier_or_ref);
        else  docElm = identifier_or_ref;
        if(docElm !== undefined && docElm != null) {}
        else  return;
    }
    else  return;
    //  if element has height 0px, we cannot determine offsetHeight, thus (if hidden) set height to auto
    var setHeightToZero = false;
    if(docElm.style.visibility == "hidden" && docElm.style.height == "0px") {
        docElm.style.height = "auto";  setHeightToZero = true;
    }
	browserDimensions();
    if(minLeft !== undefined && isNumber(minLeft)) {}  	else  minLeft = 0;
	if(minTop !== undefined && isNumber(minTop)) {}		else  minTop = 0;
    //  horizontal -----------------------------------------------------------------------
    if(hori_vert == "both" || hori_vert == "hori" || hori_vert == "left") {  
        var horizontal_margin = globals["browserWidth"] - docElm.offsetWidth;
    	if(prefer_minLeft !== undefined && prefer_minLeft != null && horizontal_margin >= minLeft) {
            docElm.style.left = "" + minLeft + "px";  }
    	else if(horizontal_margin > (2 * minLeft)) {  
            if(relationLeft !== undefined && relationLeft != null) {
                docElm.style.left = "" + parseInt(horizontal_margin * relationLeft, 10) + "px";  }
            else {
                docElm.style.left = "" + parseInt(horizontal_margin / 2, 10) + "px";  }
        }
        else if(horizontal_margin >= minLeft)  docElm.style.left = "" + minLeft + "px";
        else if(horizontal_margin >= 0)  docElm.style.left = "" + horizontal_margin + "px";
        else {  // horizontal margin is negative
            docElm.style.position = "absolute"; // trigger scroll (fixed does not do that)
            docElm.style.left = "0px";
        }
    }
    //  vertical -------------------------------------------------------------------------
    if(hori_vert == "both" || hori_vert == "vert" || hori_vert == "top") {
        var vertical_margin = globals["browserHeight"] - docElm.offsetHeight;
        if(prefer_minTop !== undefined && prefer_minTop != null && vertical_margin >= minTop)
            docElm.style.top = "" + minTop + "px";
    	else if(vertical_margin > (2 * minTop)) {
            if(relationTop !== undefined && relationTop != null)
                docElm.style.top = "" + parseInt(vertical_margin * relationTop, 10) + "px";
            else  docElm.style.top = "" + parseInt(vertical_margin / 2, 10) + "px";
        }
        else if(vertical_margin >= minTop)  docElm.style.top = "" + minTop + "px";
        else if(vertical_margin >= 0)  docElm.style.top = "" + vertical_margin + "px";
        else {  // vertical margin is negative
            docElm.style.position = "absolute"; // trigger scroll (fixed does not do that)
            docElm.style.top = "0px";
        }
    }
    //  set height back to zero?
    if(setHeightToZero == true)  docElm.style.height = "0px";
    //  cookie stored coords for movable object? -----------------------------------------
    if(ignoreStoredPosition !== undefined && ignoreStoredPosition == true)  return;
    //  we have to do this so late, to ensure check for positioning fixed/absolute
    var endPosition;
	if(typeof identifier_or_ref == "string" 
	&& (endPosition = readCookie("movableElement_endPosition__" + identifier_or_ref)) !== null
	&& endPosition.length > 1) {
	    var endPositionArr = endPosition.split("_");
	    //  check that browser size is precisely the same as in last page load
	    if(parseInt(endPositionArr[0],10) != globals["browserWidth"]
	    || parseInt(endPositionArr[1],10) != globals["browserHeight"])  return;
	    docElm.style.left = "" + parseInt(endPositionArr[2],10) + "px";
	    docElm.style.top = "" + parseInt(endPositionArr[3],10) + "px";
	}
}

//	show/hide ------------------------------------------------------------------------------------------------
//	visibility, turn on/off
//  - element must have height:auto when visible
//  - element must consist of 2 outer divs, if next child is table
/*void*/ function showHide(identifier_or_ref, visibility, /*optionals:*//*millisec*/delay,
        /*str(auto|visible)*/overflow_whenVisible/*=visible*/) {
    if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
    else  var docElm = identifier_or_ref;
    if(docElm !== undefined && docElm != null) {}  else  return;
	var new_height;  var new_overflow;  var new_visibility;
	switch(visibility) {
		case 0:  case "hidden":  case "hide":
			new_height = "0px";  new_overflow = "hidden";  new_visibility = "hidden";
			break;
		default: // visible
		    if(overflow_whenVisible !== undefined && overflow_whenVisible == "auto")  new_overflow = "auto";
		    else  new_overflow = "visible";
		    new_height = "auto";  new_visibility = "visible";		
	}
	if(delay !== undefined && delay > 0) {
		var timer = setTimeout(
	        function() {
	            docElm.style.height = new_height;  docElm.style.overflow = new_overflow;
				docElm.style.visibility = new_visibility;
	        }, delay
	    );
	}
	else {
		docElm.style.height = new_height;  docElm.style.overflow = new_overflow;
		docElm.style.visibility = new_visibility;
	}
}

//	display, turn on/off
/*void*/ function displayHide(identifier_or_ref, visibility, /*optionals*//*millisecs*/ delay,
        /*str*/display_whenVisible/*=block*/) { 
	if(typeof identifier_or_ref == "string")  var docElm = getDocElm(identifier_or_ref);
    else  var docElm = identifier_or_ref;
    if(docElm !== undefined && docElm != null) {}  else  return;
    var new_display;
    switch(visibility) {
		case 0:  case "hidden":  case "hide":
			new_display = "none";  break;
		default:
		    if(display_whenVisible !== undefined) {
		        switch(display_whenVisible) {
		            case "table":  new_display = UAFIX_displayTable;  break;
		            case "table-cell":  new_display = UAFIX_displayTableCell;  break;
		            default:  new_display = display_whenVisible;
		        }
		    }
			else  new_display = "block";
	}
	if(delay !== undefined && delay > 0) {
		var timer = setTimeout(
	        function() {
	            if(docElm !== undefined)  docElm.style.display = new_display;
	        }, delay
	    );
	}
	else  docElm.style.display = new_display;
}

//	moveElement ----------------------------------------------------------------------------------------------
/*object*/ function movableElement(id_movableObject, id_triggerObject, ghost, memorize_endPosition) {
    var _this; // global ref to this
    var _id_movableObject = id_movableObject;
    var _movableObject = getDocElm(id_movableObject);
    var _triggerObject = getDocElm(id_triggerObject);
	var _useGhost = false;
	var _ghost = null;
	if(ghost && typeof ghost == "string" && document.getElementById(ghost) !== undefined) {
		_useGhost = true;  _ghost = document.getElementById(ghost);
	}
	var _cookieStore_endPosition = false;
	if(memorize_endPosition !== undefined && memorize_endPosition == 1)  _cookieStore_endPosition = true;	
    var _doMove = false;
    var _inMotion = false;
    var _lastTime = 0;
    var _minimumMoveInterval = 10; // millisecs, skip some movements if user moves mouse very fast    
    var _currentLeft = 0;
    var _currentTop = 0;
    var _mouseOriginLeft = 0;
    var _mouseOriginTop = 0;
    //  only necessary when using ghost
    var _movableObject_visibleWidth = 0; // offsetWidth
    var _movableObject_visibleHeight = 0; // offsetHeight
    var _movableObject_styleHeight = "auto";

    //  public methods -------------------------------------------------------------------
    
    /*void*/ function actionRelay(e) { // standard (add/remove-Eventlistener
        var windowEvent = e;
        if(_this == null)  _this = globals["movableElement_objects"][_id_movableObject];
        switch(windowEvent.type) {
            case "mouseover":
                var timer0 = setTimeout(  function() {  _triggerObject.style.cursor = "move";  }, 50  );
                var timer1 = setTimeout(  function() {  _triggerObject.style.cursor = "default";  }, 250  );
                break;
            case "mousedown":
                document.addEventListener("mousemove", _this.actionRelay, false);
                document.addEventListener("mouseup", _this.actionRelay, false);
                startMove(windowEvent);
                break;
            case "mousemove":  move(windowEvent);  break;
            case "mouseup":
                document.removeEventListener("mousemove", _this.actionRelay, false);
                document.removeEventListener("mouseup", _this.actionRelay, false);
                stopMove();
                break;
            default: // nada
        }
    } 
    
    /*void*/ function actionRelay_ie(e) { // IE, attach/detach crap
        var windowEvent = window.event;
        if(_this == null)  _this = globals["movableElement_objects"][_id_movableObject];
        switch(windowEvent.type) {
            case "mouseover":
                var timer0 = setTimeout(  function() {  _triggerObject.style.cursor = "move";  }, 50  );
                var timer1 = setTimeout(  function() {  _triggerObject.style.cursor = "default";  }, 250  );
                break;
            case "mousedown":
                document.attachEvent("onmousemove", _this.actionRelay, false);
                document.attachEvent("onmouseup", _this.actionRelay, false);
                startMove(windowEvent);
                break;
            case "mousemove":  move(windowEvent);  break;
            case "mouseup":
                document.detachEvent("onmousemove", _this.actionRelay, false);
                document.detachEvent("onmouseup", _this.actionRelay, false);
                stopMove();
                break;
            default: // nada
        }
    } 

    /*void*/ function stopMove() {
        _doMove = false; // cancel further movement
        //  using ghost?
        if(_useGhost == true) {
            //  show real movable object -----------------------------
            _movableObject.style.height = _movableObject_styleHeight;
            _movableObject.style.left = "" + _currentLeft + "px";
            _movableObject.style.top = "" + _currentTop + "px";         
            showHide(_movableObject, 1);
            //  hide ghost -------------------------------------------
            showHide(_ghost, 0);
            _ghost.style.width = "0px";
            _ghost.style.left = "0px";  _ghost.style.top = "0px";           
        }
        else {
            _triggerObject.style.cursor = "default";
        }   
        _lastTime = 0; // reset 
        if(_cookieStore_endPosition == true)
            setCookie("movableElement_endPosition__" + _id_movableObject, "" + globals["browserWidth"]
                   + "_" + globals["browserHeight"] + "_" + _currentLeft + "_" + _currentTop + "");        
    } this.stopMove = stopMove;
    
    //  private methods ------------------------------------------------------------------

    /*void*/ function startMove(windowEvent) {
        //  get mouse origin -----------------------------------------
        var mousePos = mousePosition(windowEvent);
        _mouseOriginLeft = mousePos[0];
        _mouseOriginTop = mousePos[1];
        //  get object origin ----------------------------------------  
        _currentLeft = getStyle(_movableObject, "left", true);                
        _currentTop = getStyle(_movableObject, "top", true);        
        //  use ghost?
        var triggerObject;
        if(_useGhost == true) {
            triggerObject = _ghost;
            //  get dimensions of the real movable object ------------
            _movableObject_visibleWidth = _movableObject.offsetWidth;
            _movableObject_visibleHeight = _movableObject.offsetHeight;
            if(_movableObject.style) // store style height for stop() 
                _movableObject_styleHeight = _movableObject.style["height"];
            else   _movableObject_styleHeight = _movableObject.currentStyle["height"]; // ie
            //  hide real movable object -----------------------------
            showHide(_movableObject, 0); 
            _movableObject.style.left = "0px";  _movableObject.style.top = "0px";
            //  show ghost -------------------------------------------
            _ghost.style.width = "" + _movableObject_visibleWidth + "px";
            _ghost.style.height = "" + _movableObject_visibleHeight + "px";
            _ghost.style.left = "" + _currentLeft + "px";
            _ghost.style.top = "" + _currentTop + "px";
            _ghost.style.visibility = "visible";
        }
        else {
            triggerObject = _triggerObject;
        }           
        //  turn move option on --------------------------------------
        _doMove = true;
        //  make move-cursor -----------------------------------------
        triggerObject.style.cursor = "move";        
    }   
    
    /*void*/ function move(windowEvent) {
        //  check if further movement has been cancelled -------------
        if(_doMove == false)  return;
        //  dont execute method, if already being executed -----------
        if(_inMotion == true)  return;      
        //  fast movement, skip move if little time passed since last move
        var checkTime = true;
        if(_lastTime == 0) {  checkTime = false;  _lastTime = new Date().getTime();  }
        //  skip move if little time passed since last move ----------
        if(checkTime == true && new Date().getTime() < _lastTime + _minimumMoveInterval) return;
        else {
            _inMotion = true;  _lastTime = new Date().getTime();
            //  move self or ghost? ----------------------------------
            var visibleMovable = _useGhost == true ? _ghost : _movableObject;
            //  get current mouse position ---------------------------
            var mousePos = mousePosition(windowEvent);
            //  move -------------------------------------------------
            visibleMovable.style.left = "" + (_currentLeft -= (_mouseOriginLeft - (mLeft=mousePos[0]))) +"px";
            visibleMovable.style.top = "" + (_currentTop -= (_mouseOriginTop - (mTop = mousePos[1]))) + "px";
            //  set mouse origins for next --------------------------- 
            _mouseOriginLeft = mLeft;
            _mouseOriginTop = mTop;
            //  make executable again --------------------------------
            _inMotion = false;      
        }
    }   
    //  constructor statements -----------------------------------------------------------
    if(USERAGENT == "ie")  this.actionRelay = actionRelay_ie;
    else  this.actionRelay = actionRelay;
}

//	minimize/maximize ----------------------------------------------------------------------------------------
var miniMaximized_elements = new Array();
/*  //  call with literal arguments: 
    miniMaximize("surrounding_element", "element_to_be_hidden", 
            new Array("min_max_button","minimize","maximize","&gt;","&lt;"),
            "positionObject_ignoreStoredPosition", new Array("left","bottom"),
            "centerObject", "both");
    // or call with single args array:
    miniMaximize(new Array("surrounding_element", "element_to_be_hidden", 
            new Array("min_max_button","minimize","maximize","&gt;","&lt;"),
            "positionObject_ignoreStoredPosition", new Array("left","bottom"),
            "centerObject", "both") );
*/
function miniMaximize(identifier, hideElement, /*arr*/ minMaxButton, minimizeFunction, minimizeParams,
		/*optionals*/ maximizeFunction, maximizeParams, initial_minMaxTo, memorize_minMax) {
    //  check for args-style call (all parameters put in single array)
    if(hideElement !== undefined) { } // literal arguments
    else {
        var args = identifier;
        var numOfArgs = identifier.length;
        for(var argKey = 0; argKey < numOfArgs; argKey++) {
            switch(argKey) {
                case 0:  var identifier = args[argKey];  break;
                case 1:  var hideElement = args[argKey];  break;
                case 2:  var minMaxButton = args[argKey];  break;
                case 3:  var minimizeFunction = args[argKey];  break;
                case 4:  var minimizeParams = args[argKey];  break;
                case 5:  var maximizeFunction = args[argKey];  break;
                case 6:  var maximizeParams = args[argKey];  break;
                case 7:  var initial_minMaxTo = args[argKey];  break;
                case 8:  var memorize_minMax = args[argKey];  break;
                default: // too many arguments
            }
        } 
    }  
	if(getDocElm(identifier) == null || getDocElm(hideElement) == null)  return;
	if(maximizeFunction !== undefined && maximizeParams !== undefined) {} // fine, use them
	else {  maximizeFunction = minimizeFunction;  maximizeParams = minimizeParams;  }
	var minMax;
	if(initial_minMaxTo !== undefined && initial_minMaxTo != null)  minMax = initial_minMaxTo;
	else if(miniMaximized_elements["identifier"])  minMax = miniMaximized_elements["identifier"];
	else  minMax = 0;
	var outerElm = getDocElm(identifier);  var innerElm = getDocElm(hideElement);
	if(memorize_minMax !== undefined && memorize_minMax == true) {
        var memorize = true;  var memoToCookie = identifier + "_-_" + hideElement + "_-_";
        var minMaxButton_buckets = minMaxButton.length;
        for(var k = 0; k < minMaxButton_buckets; k++) {
            if(k > 0)  memoToCookie += "__";
            memoToCookie += minMaxButton[k];
        }
	}
	else  var memorize = false;
	//	minimize -----------------------------------------------------
	if(minMax == 0) {
	    //  hide inner element
	    var hideElement_tagName;
	    if( (hideElement_tagName = getDocElm(hideElement).tagName.toLowerCase()) == "table"
	    || hideElement_tagName == "td")  displayHide(hideElement, 0);
		else  showHide(hideElement, 0); 
		var paramLength = minimizeParams.length;
		if(minimizeFunction == "positionObject" 
		|| minimizeFunction == "positionObject_ignoreStoredPosition") { // takes 4 args (+ identifier)
			if(paramLength < 4) {
				for(var i = paramLength; i < 4; i++)  minimizeParams[i] = null;
			}
			var loopStarted = time();  // wait till inner element actually is hidden
            while(innerElm.offsetHeight > 0) {  if(time() > loopStarted + 5)  break;  }
			if(minimizeFunction == "positionObject")
			    positionObject(identifier, minimizeParams[0], minimizeParams[1], minimizeParams[2],
					    minimizeParams[3]);
			else
			    positionObject_ignoreStoredPosition(identifier, minimizeParams[0], minimizeParams[1],
			            minimizeParams[2], minimizeParams[3]);		            
            if(memorize == true) {
                memoToCookie += "_-_positionObject_-_";
    			for(var j = 0; j < 4; j++) {
    			    if(j > 0)  memoToCookie += "__";
    			    switch(minimizeParams[j]) {
    			    	case null:  memoToCookie += "n-u-l-l";  break;
    			    	case true:  memoToCookie += "t-r-u-e";  break;
    			    	case false:  memoToCookie += "f-a-l-s-e";  break;
    			    	default:  memoToCookie += "" + minimizeParams[j] + "";
    			    }
    			}
    			memoToCookie += "_-_n-u-l-l_-_n-u-l-l";
            }					    
		}
		else { // centerObject, takes 7 args (+ identifier)
			if(paramLength < 7) {
				for(var i = paramLength; i < 7; i++)  minimizeParams[i] = null;
			}
			var loopStarted = time();  // wait till inner element actually is hidden
            while(innerElm.offsetHeight > 0) {  if(time() > loopStarted + 5)  break;  }
			if(minimizeFunction == "centerObject")
			    centerObject(identifier, minimizeParams[0], minimizeParams[1], minimizeParams[2],
					    minimizeParams[3], minimizeParams[4], minimizeParams[5], minimizeParams[6]);
			else
			    centerObject_ignoreStoredPosition(identifier, minimizeParams[0], minimizeParams[1],
			            minimizeParams[2],
					    minimizeParams[3], minimizeParams[4], minimizeParams[5], minimizeParams[6]);
		    if(memorize == true) {
                memoToCookie += "_-_centerObject_-_";
    			for(var j = 0; j < 7; j++) {
    			    if(j > 0)  memoToCookie += "__";
    			    switch(minimizeParams[j]) {    			        
    			    	case null:  memoToCookie += "n-u-l-l";  break;
    			    	case true:  memoToCookie += "t-r-u-e";  break;
    			    	case false:  memoToCookie += "f-a-l-s-e";  break;
    			    	default:  memoToCookie += "" + minimizeParams[j] + "";
    			    }
    			}
    			memoToCookie += "_-_n-u-l-l_-_n-u-l-l";
		    }					    
		}
		var docElm_minMaxButton = null;
		if(minMaxButton != null && minMaxButton[0] && minMaxButton[2]
		&& (docElm_minMaxButton = getDocElm(minMaxButton[0])) != null) {
		    docElm_minMaxButton.title = minMaxButton[2];
			if(minMaxButton[3] && minMaxButton[4])  docElm_minMaxButton.innerHTML = minMaxButton[4];
		}
	}
	//	maximize -----------------------------------------------------
	else {
	    //  show inner element
	    var hideElement_tagName;
        if( (hideElement_tagName = getDocElm(hideElement).tagName.toLowerCase()) == "table"
        || hideElement_tagName == "td")  displayHide(hideElement, 1);
		else  showHide(hideElement, 1); 
		var paramLength = maximizeParams.length;
		if(maximizeFunction == "positionObject") { // takes 4 args (+ identifier)
			if(paramLength < 4) {
				for(var i = paramLength; i < 4; i++)  maximizeParams[i] = null;
			}
			var loopStarted = time();  // wait till inner element actually is shown
            while(innerElm.offsetHeight == 0) {  if(time() > loopStarted + 5)  break;  }
			positionObject(identifier, maximizeParams[0], maximizeParams[1], maximizeParams[2],
					maximizeParams[3]);
            if(memorize == true) {
                memoToCookie += "_-_n-u-l-l_-_n-u-l-l_-_positionObject_-_";
                for(var j = 0; j < 4; j++) {
                    if(j > 0)  memoToCookie += "__";
                    switch(maximizeParams[j]) {
                        case null:  memoToCookie += "n-u-l-l";  break;
                        case true:  memoToCookie += "t-r-u-e";  break;
                        case false:  memoToCookie += "f-a-l-s-e";  break;
                        default:  memoToCookie += "" + maximizeParams[j] + "";
                    }
                }
            }	      
		}
		else { // centerObject, takes 7 args (+ identifier)
			if(paramLength < 7) {
				for(var i = paramLength; i < 7; i++)  maximizeParams[i] = null;
			}
			var loopStarted = time();  // wait till inner element actually is shown
			while(innerElm.offsetHeight == 0) {  if(time() > loopStarted + 5)  break;  }
			centerObject(identifier, maximizeParams[0], maximizeParams[1], maximizeParams[2],
					maximizeParams[3], maximizeParams[4], maximizeParams[5], maximizeParams[6]);
            if(memorize == true) {
                memoToCookie += "_-_n-u-l-l_-_n-u-l-l_-_centerObject_-_";
                for(var j = 0; j < 7; j++) {
                    if(j > 0)  memoToCookie += "__";
                    switch(maximizeParams[j]) {
                        case null:  memoToCookie += "n-u-l-l";  break;
                        case true:  memoToCookie += "t-r-u-e";  break;
                        case false:  memoToCookie += "f-a-l-s-e";  break;
                        default:  memoToCookie += "" + maximizeParams[j] + "";
                    }
                }
            }
		}
		var docElm_minMaxButton = null;
        if(minMaxButton != null && minMaxButton[0] && minMaxButton[1]
		&& (docElm_minMaxButton = getDocElm(minMaxButton[0])) != null) {
            docElm_minMaxButton.title = minMaxButton[1];
            if(minMaxButton[3])  docElm_minMaxButton.innerHTML = minMaxButton[3];
        }
	}
	//	set for next -------------------------------------------------
	if(minMax == 0)  miniMaximized_elements["identifier"] = 1;
	else  miniMaximized_elements["identifier"] = 0;
	//  cookie store state? ------------------------------------------
	if(memorize == true) {
	    var storedString = "";
	    if(issetCookie("minMaxes_memorized") && (storedString = readCookie("minMaxes_memorized")).length > 0){ 
	        //  dont store more than one instance of current element
	        var storedArray = storedString.split("|-|");  var numOfStored = storedArray.length;
	        var identifierLength = identifier.length + 3;  storedString = "";  var foundSelf = false;
	        for(var m = 0; m < numOfStored; m++) {
	            if(m > 0)  storedString += "|-|";
	            if(storedArray[m].substr(0, identifierLength) == identifier + "_-_") {
                    foundSelf = true;  storedString += memoToCookie + "_-_" + minMax;
	            }
                else  storedString += storedArray[m];
	        }
	        if(!foundSelf)  storedString += "|-|" + memoToCookie + "_-_" + minMax;
	        setCookie("minMaxes_memorized", storedString);
	    }
	    else  setCookie("minMaxes_memorized", memoToCookie + "_-_" + minMax);    
    }
}

/*voi*/ function miniMaximize_memorized_onOnload() {
    var storedString = "";
    if(issetCookie("minMaxes_memorized") && (storedString = readCookie("minMaxes_memorized")).length > 0) {
        var storedArray = storedString.split("|-|");  var numOfStored = storedArray.length;
        var memoArray;  var noOfMemoBuckets;  var identifier;  var minMax; 
        var subArray;  var noOfSubBuckets;  
        var mmArgs;  var j;  var k;  var subBucket;
        for(var i = 0; i < numOfStored; i++) {
            memoArray = storedArray[i].split("_-_");  noOfMemoBuckets = memoArray.length;
            identifier = memoArray[0];  
            //  check if the element exists at all in this load
            if(getDocElm(identifier, null, true) == null)  continue;
            //  unfortunately we cant check if the desired state is the same state
            //  that the element currently has (could if we checked for the cookie in PHP, but dont care to)
            mmArgs = new Array(noOfMemoBuckets);  
            mmArgs[0] = identifier;
            mmArgs[noOfMemoBuckets - 1] = parseInt(memoArray[noOfMemoBuckets - 1],10); // minMax  
            for(j = 1; j < noOfMemoBuckets - 1; j++) {
                subArray = memoArray[j].split("__");  
                if( (noOfSubBuckets = subArray.length) > 1) {
                    for(k = 0; k < noOfSubBuckets; k++) {
                        //  unpack args from string 
                        subBucket = subArray[k];
                        if(subBucket.search(/[^0-9]/) == -1) // only numbers
                            subArray[k] = parseInt(subBucket,10);
                        else {      
                            switch(subBucket) { 
                                case "n-u-l-l":  subArray[k] = null;  break;
                                case "t-r-u-e":  subArray[k] = true;  break;
                                case "f-a-l-s-e":  subArray[k] = false;  break;
                                default:  subArray[k] = subBucket;
                            }
                        }
                    }
                    mmArgs[j] = subArray;
                }
                else  mmArgs[j] = memoArray[j];            
            }
            try {  miniMaximize(mmArgs);  }
            catch(minMaxError) {   
                if(DEBUG !== undefined && DEBUG > 0)  alert(minMaxError);
            }
        }
    }
}


//	DOM ------------------------------------------------------------------------------------------------------
/*bool*/ function hasChildTag(docElm) {
	if(!docElm.childNodes)  return false; // safer
	var noOfChildren = docElm.childNodes.length;
	for(var i = 0; i < noOfChildren; i++) {
		if(i == 0 && !docElm.childNodes[i])  return false; // some would err in next line, if without this
		if(docElm.childNodes[i].nodeType == 1)  return true;
	}	
	return false;
} 

//  diable text selection -----------------------------------------------------------------------------------
//	- disabling text selection is irreversible, you cannot re-enable text selection
//	- disabled text selection is inherited, thus you have to go for the lowest level ever possible

globals["disableTextSelection_skipIds"] = new Array();

/*void*/ function disable_textSelection(docElm) {
	if(USERAGENT == "ie") {
		docElm.onselectstart = function() {  return false;  };
	    docElm.unselectable = "on";
	}
	else  docElm.style.MozUserSelect = "none";
}

/*object*/ function disable_textSelection_all() {
/*	- disables text selection on all elements, except form elements: input, textarea, select and option
*	- tries to eliminate cursor:text, by doing cursor:default on all elements that:
*		- is not a form element (see above), and is not: img, a, area
*		- has no class attribute (has no css-class attached directly on the element)
*/	
	/*private void*/ function traverseNodes(element) { // recursive
		//	iterate children, if any -----------------------------------------------------
		var noOfChildren = element.childNodes.length;	
		var someChild_hasChildTag = false;  var someChild_isTextNode = false;
		var someChild_isFormField = false;  var someChild_isSkipId = false;
		var currentChild;
		for(var i = 0; i < noOfChildren; i++) {
			currentChild = element.childNodes[i];
			//	check if there is a child text node, and skip --------
			if(currentChild.nodeType == 3) {
				someChild_isTextNode = true;  continue;
			}
			//	skip children that arent tags ------------------------
			if(currentChild.nodeType != 1)  continue; // not a tag
			//	check if child is/has an id that should be skipped ---
			if(currentChild.id !== undefined 
			&& currentChild.id.length > 0 && globals["disableTextSelection_skipIds"][ currentChild.id ]) {
				someChild_isSkipId = true;	 continue;	
			}				
			//	if child has a child tag, dive into that tag ---------
			if(hasChildTag(currentChild) == true) {
				someChild_hasChildTag = true;
				traverseNodes(currentChild); // recursion
			}			
			else {
				//	check if child is form field ---------------------
				if(currentChild.tagName !== undefined 
				&& (currentChild.tagName == "INPUT" || currentChild.tagName == "TEXTAREA" 
				|| currentChild.tagName == "SELECT" || currentChild.tagName == "OPTION")) 
				    someChild_isFormField = true;			
				//  child tag with no children, and not form field ---
				else {	
					//	disable text selection ---
					disable_textSelection(currentChild);
					//	make cursor default? (only if non-specific cursor, and element has no css-class)
					if(currentChild.tagName !== undefined 
					&& currentChild.tagName != "IMG" 
					&& currentChild.tagName != "A" && currentChild.tagName != "AREA" 
					&& cursor_nonSpecific_or_text(currentChild) == true
					&& !currentChild.className)
						currentChild.style.cursor = "default";
				}
			}
		}	
		//	tag is not form field, and not an id to be skipped --------
		if(someChild_hasChildTag == false && someChild_isFormField == false && someChild_isSkipId == false) {
			//	disable text selection -----------
			disable_textSelection(element);
			//	make cursor default? (only if non-specific cursor, and element has no css-class)
			if(someChild_isTextNode == true
			&& element.tagName !== undefined 
			&& element.tagName != "IMG" && element.tagName != "A" && element.tagName != "AREA"
			&& cursor_nonSpecific_or_text(element) == true
			&& !element.className)
				element.style.cursor = "default";
		}
	}
	
	/*private bool*/ function cursor_nonSpecific_or_text(docElm) {
		var styleArr;
		if(USERAGENT == "ie") {
			if(!docElm.currentStyle)  return false; // ie would sometimes err here
			styleArr = docElm.currentStyle;
		}
		else {
			if(!docElm.style)  return false; // other browsers would probably sometimes err here
			styleArr = docElm.style;
		}
		switch(styleArr["cursor"]) {
			//  skip: auto|default|text|inherit
			case "pointer":  case "hand":
			case "move":  case "help":  case "wait":  case "crosshair":  
			case "e-resize":  case "ne-resize":  case "nw-resize":  case "n-resize":  
			case "se-resize":  case "sw-resize":  case "s-resize":  case "w-resize":			
				return false;
			default:  return true;
		}
	}
	
	//	constructor ----------------------------------------------------------------------	
	traverseNodes(document.body); // roll it!
}

//  scrollbar width/height -----------------------------------------------------------------------------------
globals['scrollbarWidth'] = 0;
function scrollbarMeter() {
	if(document.getElementById("scrollbarMeter")) {
		var docElm_scrollMeterOuter = document.getElementById("scrollbarMeter");
		var docElm_scrollMeterInner = document.getElementById("scrollbarMeterInner");
		docElm_scrollMeterOuter.style.display = "block";		
		var noscrollWidth = docElm_scrollMeterInner.offsetWidth;
		if(USERAGENT == "ie" && USERAGENTversion > 6) {
			docElm_scrollMeterOuter.style.overflow = "scroll";
			globals['scrollbarWidth'] = noscrollWidth - docElm_scrollMeterOuter.clientWidth;
		}
		else {
            docElm_scrollMeterOuter.style.overflow = "auto";
            globals['scrollbarWidth'] = noscrollWidth - docElm_scrollMeterInner.offsetWidth;
		}
		docElm_scrollMeterOuter.style.display = "none";
	}
}
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*/                                    /*  simple-complex tinySimple CMS v. 0.9.60 - www.tinysimple.net  */
/*///// system settings ////////////////////////////////////////////////////////////////////////////////////*/

globals['browsers'] = {
        'minimal_minWidth':760, 'minimal_minHeight':430,
        'ideal_minWidth':990, 'ideal_minHeight':580,
        'ideal_maxWidth':1020, 'ideal_maxHeight':610,
        'large_minWidth':1220, 'large_minHeight':760
};

//  dont ever disable text selection on error response dialBox
//  (user must be able to select and search for error message on net
globals["disableTextSelection_skipIds"]["dialBox_errorResponse_content"] = true;
//  whether browser height always counts as tallest interesting value
//  (if content is embedded in scrollable div, it must be 1)
globals["allHeight_browserHeightRules"] = 0; // default not, old scroll till you die...

var imagePopViewer_totalShadeBorderWidth = 3;
var imagePopViewer_subTextBoxHeight = 18;

var tinySimpleLink_horiPositionModifier = -1;
var tinySimpleLink_vertPositionModifier = 0;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*/									/*  simple-complex tinySimple CMS v. 0.9.71 - www.tinysimple.net  */
/*///// system /////////////////////////////////////////////////////////////////////////////////////////////*/

if(USERAGENT == "ie" && USERAGENTversion < 7)  var JSvoid = "#";
else  var JSvoid = "javascript:void(0);";

//  jsAlert boxes --------------------------------------------------------------------------------------------
var jsAlert_onClose_focusOn;
var jsAlert_cancel_suppressable = false;
/*void*/ function jsAlert(message, /*bool*/isWarning, /*identifier_or_ref*/onClose_focusOn/*=null*/,
        /*bool*/suppressable_awaitOverrulingEvents/*=false*/) {
    if(isWarning !== undefined && isWarning == true) // send all warnings to medium sized alert box
        return jsAlertMedium(message, true, onClose_focusOn, suppressable_awaitOverrulingEvents);
        //getDocElm("jsAlertBox_top").className = "top_warning";
    else  getDocElm("jsAlertBox_top").className = "top_success";
    getDocElm("jsAlertBox_content").innerHTML = nl2br(message);
    if(onClose_focusOn !== undefined && onClose_focusOn != null)  jsAlert_onClose_focusOn = onClose_focusOn;
    else  jsAlert_onClose_focusOn = null;
    if(suppressable_awaitOverrulingEvents !== undefined && suppressable_awaitOverrulingEvents == true)
        var suppressableTimer = setTimeout(
	        function() {
	            jsAlert_suppressable_show();
	        }, 10
	    );
	else {  showHide("jsAlertBox", 1);  focusChecked("jsAlertBox_closeButton");  }
}
/*void*/ function jsAlert_hide() {
    showHide("jsAlertBox", 0);
    if(jsAlert_onClose_focusOn !== undefined && jsAlert_onClose_focusOn != null)
        focusChecked(jsAlert_onClose_focusOn);
}
/*void*/ function jsAlert_suppressable_show() {
    if(jsAlert_cancel_suppressable == true) {
        jsAlert_cancel_suppressable = false;  return;
    }
    else {  showHide("jsAlertBox", 1);  focusChecked("jsAlertBox_closeButton");  }
}

var jsAlertMedium_onClose_focusOn;
var jsAlertMedium_cancel_suppressable = false;
/*void*/ function jsAlertMedium(message, /*bool*/isWarning, /*identifier_or_ref*/onClose_focusOn/*=null*/,
        /*bool*/suppressable_awaitOverrulingEvents/*=false*/) {
    if(document.getElementById("jsAlertMedium") === undefined) // if this alert box doesnt exist, try other
        return jsAlert(message, isWarning, onClose_focusOn, suppressable_awaitOverrulingEvents);
    if(isWarning !== undefined && isWarning == true)
        getDocElm("jsAlertMediumBox_top").className = "top_warning";
    else  getDocElm("jsAlertMediumBox_top").className = "top_success";
    getDocElm("jsAlertMediumBox_content").innerHTML = nl2br(message);
    if(onClose_focusOn !== undefined && onClose_focusOn != null)  jsAlertMedium_onClose_focusOn = onClose_focusOn;
    else  jsAlertMedium_onClose_focusOn = null;
    if(suppressable_awaitOverrulingEvents !== undefined && suppressable_awaitOverrulingEvents == true)
        var suppressableTimer = setTimeout(
            function() {
                jsAlertMedium_suppressable_show();
            }, 10
        );
    else {  showHide("jsAlertMediumBox", 1);  focusChecked("jsAlertMediumBox_closeButton");  }
}
/*void*/ function jsAlertMedium_hide() {
    showHide("jsAlertMediumBox", 0);
    if(jsAlertMedium_onClose_focusOn !== undefined && jsAlertMedium_onClose_focusOn != null)
        focusChecked(jsAlertMedium_onClose_focusOn);
}
/*void*/ function jsAlertMedium_suppressable_show() {
    if(jsAlertMedium_cancel_suppressable == true) {
        jsAlertMedium_cancel_suppressable = false;  return;
    }
    else {  showHide("jsAlertMediumBox", 1);  focusChecked("jsAlertMediumBox_closeButton");  }
}

var jsConfirm_onResponse_removeListeners = new Array();
/*void*/ function jsConfirm(message, onYes_functionName, onNo_functionName) {
    jsAlert_cancel_suppressable = true; // kill any  jsAlert
    getDocElm("jsConfirmBox_content").innerHTML
            = "<p class=\"firstParagraph\">" + doubleNewlineP_singleNewlineBr(message) + "</p>\n";
    if(onYes_functionName !== undefined && onYes_functionName != null)
        addRegEventListener("jsConfirmBox_yes", "click", onYes_functionName);
    if(onNo_functionName !== undefined && onNo_functionName != null)
        addRegEventListener("jsConfirmBox_no", "click", onNo_functionName);
    showHide("jsAlertBox", 0); // kill popped alert
    showHide("jsConfirmBox", 1);
    focusChecked("jsConfirmBox_yesButton");
}
/*void*/ function jsConfirm_hide() {
    showHide("jsConfirmBox", 0);
}

//  login/out ------------------------------------------------------------------------------------------------
/*void*/ function login_prompt() {
	var form = document.forms["controlForm"];
	form.elements["actionName"].value = "login";
	form.elements["actionValue"].value = "prompt";
	form.submit();
}

/*void*/ function login_logout() {
	document.forms["logoutForm"].submit();
}

//  canvas cover ---------------------------------------------------------------------------------------------
/*void*/ function resize_canvasCover() {
    if(getDocElm("system_canvasCover") != null) { // if it exists
        var canvasCover = getDocElm("system_canvasCover");
        if(canvasCover.offsetWidth > 50) { // if its expanded
            browserDimensions();
            canvasCover.style.width = "" + globals["browserWidth"] + "px";
            canvasCover.style.height = "" + globals["browserHeight"] + "px";
        }
    }
}
/*void*/ function coverCanvas(/*bool*/show/*=true*/) {
    if(getDocElm("system_canvasCover") != null) { // if it exists
        var canvasCover = getDocElm("system_canvasCover");
        var width = 0;  var height = 0;  var visibility = "hidden";
        if(show !== undefined && show == false) { } // keep default zeros and hidden
        else {
            browserDimensions();  width = globals["browserWidth"];  height = globals["browserHeight"];
            visibility = "visible";
        }
        canvasCover.style.width = "" + width + "px";
        canvasCover.style.height = "" + height + "px";
        canvasCover.style.visibility = visibility;
    }
}

//  contentBox width -----------------------------------------------------------------------------------------
var template_contentBoxWidth = {
    "isWide":0, // bool 0|1
    "normal_max":null, "normal_min":null, 
    "wide_max":null, "wide_min":null,
    "maximum":null, "minimum":null // final values to use in template
};
/*void*/ function establish_template_contentBoxWidth() { // called at onload
    template_contentBoxWidth["maximum"] = template_contentBoxWidth["normal_max"];
    template_contentBoxWidth["minimum"] = template_contentBoxWidth["normal_min"];
    if(getDocElm("contentBox_widthFlag_noRealStyle", null, true) != null)
        template_contentBoxWidth["isWide"] = getStyle("contentBox_widthFlag_noRealStyle", "width", true);
    if(template_contentBoxWidth["isWide"] == 1) { 
        template_contentBoxWidth["maximum"] = template_contentBoxWidth["wide_max"];
        template_contentBoxWidth["minimum"] = template_contentBoxWidth["wide_min"];
    }
}

//  image pop viewer -----------------------------------------------------------------------------------------
/*bool*/ function imagePop(imageId, positionLeft, positionTop) {
    ImagePop.show(imageId, positionLeft, positionTop);  
}
var popImage = imagePop; // alias
var singleton_imagePopViewer = 0;
/*singleton class*/ function imagePopViewer(imageMap, hoverTitle, zIndex) {
    var _firstPop = true;
    var _images = new Map(null, "imagePopViewer_images");
    var _hoverTitle = "click to hide";
    var _zIndex = 400;
    var _currentImage = null;
    var _docElm_box, _docElm_image, _docElm_subText = null;
    
    /*bool*/ this.show = function(imageId, positionLeft, positionTop) {
//alert(_images.length);
        //  get mouse position ---------------------------------------
        var mouseHori = globals["mouseHori"];  var mouseVert = globals["mouseVert"];
        var imageName = null;  var posLeft, posTop = 0;  var establishedImage = false;
        //  new image, current image, or no image (error) ------------
        if(imageId !== undefined && imageId != null && imageId.length > 0 && _images.isset(imageId)){
            establishedImage = true;  imageName = imageId;  _currentImage = imageId;
        }
        else if(_currentImage != null) {  establishedImage = true;  imageName = _currentImage;  }
        else if(_images.length() > 0) { // find last added
            if( (imageName = _images.end(true)) != false)  establishedImage = true;
        }
        if(establishedImage == false) {            
            if(DEBUG > 0) {
                var em_noImage;
                if(imageId !== undefined && imageId != null && imageId.length > 0)
                    em_noImage = "id[" + imageId + "] because it hasnt been added"
                            + " to imagePopViewer objects list of images";
                else  em_noImage = "because no imageId argument given";
                jsAlert("imagePopViewer:show: cannot show image " + em_noImage, true); 
            } 
            return false;  
        }
        //  pick up refs, if not used before -------------------------
        if(_firstPop == true) {
            _firstPop = false;
            _docElm_box = getDocElm("imagePopBox");
            if(_docElm_box == null) {
                if(DEBUG > 0)  jsAlert("imagePopViewer:show: cannot show any image, because cannot find"
                        + " document element[imagePopBox]", true);
                return false;  
            }
            _docElm_image = getDocElm("imagePopBox_image");
            _docElm_subText = getDocElm("imagePopBox_subText");
        }
        //  avoid flash of old picture, when showing new without having closed old
        _docElm_box.style.visibility = "hidden";
        //  fetch image properties -----------------------------------
        var url, width, height, subText, borderWidth, borderColor;  
        url = _images.g(imageName).g("url");
        width = _images.g(imageName).g("width");  height = _images.g(imageName).g("height");
        subText = _images.g(imageName).g("subText");
        borderWidth = _images.g(imageName).g("borderWidth");
        borderColor = _images.g(imageName).g("borderColor");
        //  establish position basis (args or mouse position) --------
        if(positionLeft !== undefined && positionLeft != null)  posLeft = positionLeft;
        else  posLeft = mouseHori;
        if(positionTop !== undefined && positionTop != null)  posTop = positionTop;
        else  posTop = mouseVert;
        //  subtext? - get height of it, if were gonna show it -------
        var subTextHeight = 0;
        if(subText != null && subText.length > 0) {
            subTextHeight = 18;
            if(imagePopViewer_subTextBoxHeight !== undefined && imagePopViewer_subTextBoxHeight > 0)
                subTextHeight = imagePopViewer_subTextBoxHeight;
        }
        //  compute the actual dimensions ----------------------------
        browserDimensions(); // get browser width/height
        var browserWidth = globals["browserWidth"];  var browserHeight = globals["browserHeight"];        
        var viewerWidth, viewerHeight, totalShadeBorderWidth = 0;
        if(imagePopViewer_totalShadeBorderWidth !== undefined
        && imagePopViewer_totalShadeBorderWidth > 0)
            totalShadeBorderWidth = imagePopViewer_totalShadeBorderWidth;
        viewerWidth = (borderWidth * 2) + totalShadeBorderWidth;
        viewerHeight = viewerWidth + subTextHeight;
        //  if the whole gets larger than browser, we have to scale down image
        if(viewerWidth + width <= browserWidth && viewerHeight + height <= browserHeight) { } // swell
        else {
            var widthDivider, heightDivider, divider = 1;
            if(viewerWidth + width > browserWidth)  widthDivider = width / (browserWidth - viewerWidth);
            if(viewerHeight + height > browserHeight)
                heightDivider = height / (browserHeight - viewerHeight);
            if(widthDivider > heightDivider)  divider = widthDivider;
            else  divider = heightDivider;
            width = Math.floor(width / divider);  
            height = Math.floor(height / divider);
        }
        viewerWidth += width;  viewerHeight += height; 
        //  load image, and set its dimensions -----------------------
        _docElm_image.src = url;
        _docElm_image.style.width = "" + width + "px";  _docElm_image.style.height = "" + height + "px";
        if(borderWidth > 0) {
            _docElm_image.style.borderWidth = "" + borderWidth + "px";
            if(borderColor.length > 0)  _docElm_image.style.borderColor = "" + borderColor + "";
        }
        else  _docElm_image.style.borderWidth = "0px";
        if(subTextHeight > 0) {
            _docElm_subText.style.display = "block";
            _docElm_subText.style.height = "" + subTextHeight + "px";
            _docElm_subText.style.maxHeight = "" + subTextHeight + "px";
            _docElm_subText.innerHTML = subText;
        }
        else  _docElm_subText.style.display = "none";
        //  position it ----------------------------------------------
        positionByCoords_dimensionsKnown(_docElm_box, viewerWidth, viewerHeight, posLeft, posTop, 
                globals["mouse_marginToPop"], 0, globals["force_fixed_absolute"]);
        //  display it -----------------------------------------------    
        _docElm_box.style.display = UAFIX_displayTable; 
        var t = setTimeout(function(){_docElm_box.style.visibility = "visible";}, 150);     
        return true;
    };
    
    /*void*/ this.hide = function() {
        if(_docElm_box) {  _docElm_box.style.display = "none";  }
    };
    
    //  call with literal arguments:  add("id", "url" /*optionals:*/ width, height, "subText" ...etc);
    //  or single args array:  add(new Array("id", "url", /*optionals:*/ width, height, "subText" ...etc) );
    /*bool*/ this.add = function(/*str|arr*/id, /*str*/url, /*int*/width, /*int*/height, /*str*/subText,
            /*int*/borderWidth, /*str*/borderColor, /*bool*/overwrite) {    
        var iWidth, iHeight, iBorderWidth = 0;  var iId, iUrl, iSubText = null, iBorderColor = "";      
        //  check for args-style call (all parameters put in single array)
        if(url !== undefined) { // literal arguments
            iUrl = url;
            if(width) {  iWidth = width;
                if(height) {  iHeight = height;
                    if(subText) {  iSubText = subText;
                        if(borderWidth) {  iBorderWidth = borderWidth;
                            if(borderColor)  iBorderColor = "#" + borderColor.replace(/\#/,"");
            }  }  }  } 
        }
        else { // args-style call ----------------
            var args = id;  var numOfArgs = id.length;
            for(var argKey = 0; argKey < numOfArgs; argKey++) {
                switch(argKey) {
                    case 0:  var iId = args[argKey];  break;
                    case 1:  var iUrl = args[argKey];  break;
                    case 2:  var iWidth = args[argKey];  break;
                    case 3:  var iHeight = args[argKey];  break;
                    case 4:  var iSubText = args[argKey];  break;
                    case 5:  var iBorderWidth = args[argKey];  break;
                    case 6:  var iBorderColor = args[argKey];  break;
                    default: // too many arguments
                }  } 
        }
        //  dont add the same image twice ----------------------------
        if(!overwrite && _images.length() > 0 && _images.isset(iId)) { 
            if(DEBUG > 0)  jsAlert("imagePopViewer:add: will not add image id[" + id
                    + "] because already added earlier", true);  return false;
        }
        //  check for empty url arg ----------------------------------
        if(!isString(iUrl) || iUrl.length == 0) { 
            if(DEBUG > 0)  jsAlert("imagePopViewer:add: cannot add image id[" + id
                    + "] because empty url arg", true);  return false;  
        }
        _images.s(id, new Map({"url":iUrl, "width":iWidth, "height":iHeight, "subText":iSubText,
                "borderWidth":iBorderWidth, "borderColor":iBorderColor}, "img__" + id) );
        return true;
    };
    
    /*private void*/ function writeViewer(title, zIndex) {
        document.getElementById("ImagePopParent").innerHTML = "<table id=\"imagePopBox\" style=\"z-index:" + zIndex + ";\"><tr>"
                + "<td class=\"horiBorder vertBorder highLightShade\">&nbsp;</td>"
                + "<td class=\"vertBorder lightShade\">&nbsp;</td>"
                + "<td class=\"horiBorder vertBorder lightShade\">&nbsp;</td>"
                + "<td class=\"horiBorder vertBorder noShade\">&nbsp;</td>"
                + "</tr><tr>" + "<td class=\"horiBorder lightShade\">&nbsp;</td>"
                + "<td id=\"imagePopBox_content\">"
                + "<img id=\"imagePopBox_image\" onclick=\"ImagePop.hide();\" alt=\"\" title=\""
                + title + "\" />"
                + "<div id=\"imagePopBox_subText\">&nbsp;</div>" + "</td>"
                + "<td class=\"horiBorder darkShade\">&nbsp;</td>"
                + "<td class=\"horiBorder lightShade\">&nbsp;</td>" + "</tr><tr>"
                + "<td class=\"horiBorder vertBorder noShade\">&nbsp;</td>"
                + "<td class=\"vertBorder darkShade\">&nbsp;</td>"
                + "<td class=\"horiBorder vertBorder darkShade\">&nbsp;</td>"
                + "<td class=\"horiBorder vertBorder noShade\">&nbsp;</td>" + "</tr></table>"; 
    }
    
    //  constructor --------------------------------------------------
    if(++singleton_imagePopViewer > 1) { 
        if(DEBUG > 0)  jsAlert("imagePopViewer is a singleton - you have instantiated twice", true);
        return false;  
    }
    if(imageMap !== undefined && imageMap != null)  _images = imageMap;
    if(hoverTitle !== undefined && hoverTitle != null && hoverTitle.length > 0)  _hoverTitle = hoverTitle;
    if(zIndex !== undefined && zIndex != null)  _zIndex = zIndex;
    writeViewer(_hoverTitle, _zIndex);
}

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*/