
// --------------------------------------------------------------------
function replaceAll(s, regx, replace){while(s.search(regx) > -1){s = s.replace(regx, replace);}return s;}
// --------------------------------------------------------------------
function left(s, i){return s.substr(0, i);}
// --------------------------------------------------------------------
function right(s, i){var max = s.length;var p;if(i < max){p = max-i;}else{p = 0;}return s.substr(p,i);}
// --------------------------------------------------------------------
function padL(s, c, i){if(i > s.length){var iFill = i - s.length;var sFill = "";for(var n = 1; n <= iFill; n++){sFill += c;}s = sFill+s;}return s;}
//-------------------------------------------------------------------
function padR(s, c, i){if(i > s.length){var iFill = i - s.length;var sFill = "";for(var n = 1; n <= iFill; n++){sFill += c;}s = s+sFill;}return s;}
//-------------------------------------------------------------------
function dateToMySQLDate(d){var y = d.getFullYear().toString();var m = padL((d.getMonth()+1).toString(),"0",2);var d = padL(d.getDate().toString(),"0",2);var s = y+"-"+m+"-"+d;return s;}
//-------------------------------------------------------------------
function dateFormat(s, format){y = "";m = "";d = "";if(s.length == 10){if(s.search(/-/) > -1){d = s.substr(8,2);m = s.substr(5,2);y = s.substr(0,4);}else if(s.search(/./) > -1){d = s.substr(0,2);m = s.substr(3,2);y = s.substr(6,4);}}else if(s.length == 8){d = s.substr(6,2);m = s.substr(4,2);y = s.substr(0,4);}format = replaceAll(format,/d/, d);format = replaceAll(format,/m/, m);format = replaceAll(format,/y/, y);return format;}
//-------------------------------------------------------------------
function getObj(s){if(s.search(/\[/) > -1){return document.getElementsByName(s);}return document.getElementById(s);}
//-------------------------------------------------------------------
function is_visible(s){if(document.getElementById(s).style.visibility == "hidden"){return false;}return true;}
//-------------------------------------------------------------------
function is_displayed(s){if(document.getElementById(s).style.display == "none"){return false;}return true;}
//-------------------------------------------------------------------
function showObj(s){document.getElementById(s).style.visibility = "visible";}
//-------------------------------------------------------------------
function hideObj(s){document.getElementById(s).style.visibility = "hidden";}
//-------------------------------------------------------------------
function displayObj(s, visible){if((typeof visible) == "string"){document.getElementById(s).style.display = visible;}else{if(!visible){document.getElementById(s).style.display = "none";}else{document.getElementById(s).style.display = "block";}}}
//-------------------------------------------------------------------
function displayObjAll(tag, needle, visible){var v = document.getElementsByTagName(tag);for(var i=0;i<v.length;i++){var id = v[i].id;if(id.search(needle) > -1){displayObj(id, visible);}}}
//-------------------------------------------------------------------
function hideObjAll(tag, needle){var v = document.getElementsByTagName(tag);for(var i=0;i<v.length;i++){var id = v[i].id;if(id.search(needle) > -1){hideObj(id);/*if(v[i].hasChildNodes()){for(var c = 0; c < v[i].childNodes.length; c++) {if(v[i].childNodes.item(c).style)v[i].childNodes.item(c).style.visibility = "hidden";}}*/}}}
//-------------------------------------------------------------------
function getObjs(s){return document.getElementsByName(s);}
//-------------------------------------------------------------------
function enableObj(s){document.getElementById(s).disabled = false;}
//-------------------------------------------------------------------
function disableObj(s){document.getElementById(s).disabled = true;}
//-------------------------------------------------------------------
function is_enabeled(s){if(document.getElementById(s).disabled = true){return false;}return true;}
//-------------------------------------------------------------------
function readOnlyObj(s, mode, color){if((typeof mode) != "boolean"){mode = true;}if((typeof color) != "string"){if(mode == true){color = "#C0C0C0";}else{color = "#FFFFFF";}}var obj = document.getElementById(s);obj.style.backgroundColor = color;obj.readOnly = mode;}
//-------------------------------------------------------------------
function getWindowWidth(){if(window.outerWidth){return window.outerWidth;
	}else if(document.documentElement && document.documentElement.offsetWidth){ // IE 6 Strict Mode
return document.documentElement.offsetWidth;}else if(document.body && document.body.offsetWidth){return document.body.offsetWidth;}else{return 0;}}
//-------------------------------------------------------------------
function getWindowHeight(){if(window.outerHeight){return window.outerHeight;
	}else if(document.documentElement && document.documentElement.offsetHeight){ // IE 6 Strict Mode
return document.documentElement.offsetHeight;}else if(document.body && document.body.offsetHeight){return document.body.offsetHeight;}else{return 0;}}
//-------------------------------------------------------------------
function getDocWidth(){if(window.innerWidth){return window.innerWidth;
	}else if(document.documentElement && document.documentElement.clientWidth){ // IE 6 Strict Mode
return document.documentElement.clientWidth;}else if(document.body && document.body.clientWidth){return document.body.clientWidth;}else{return 0;}}
//-------------------------------------------------------------------
function getDocHeight(){if(window.innerHeight){return window.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight){ // IE 6 Strict Mode
return document.documentElement.clientHeight;}else if(document.body && document.body.clientHeight){return document.body.clientHeight;}else{return 0;}}
//-------------------------------------------------------------------
function getScrollX(){if(self.pageXOffset){return self.pageXOffset;
   }else if(document.documentElement && document.documentElement.scrollLeft){ // IE 6 Strict Mode
return document.documentElement.scrollLeft;}else if(document.body){return document.body.scrollLeft;}else{return 0;}}
//-------------------------------------------------------------------
function getScrollY(){if(self.pageYOffset){return self.pageYOffset;
   }else if(document.documentElement && document.documentElement.scrollTop){ // IE 6 Strict Mode
return document.documentElement.scrollTop;}else if(document.body){return document.body.scrollTop;}else{return 0;}}
//-------------------------------------------------------------------
function getPageWidth(){if(document.body.scrollWidth > document.body.offsetWidth){return document.body.scrollWidth;}else{return document.body.offsetWidth;}}
//-------------------------------------------------------------------
function getPageHeight(){if(document.body.scrollHeight > document.body.offsetHeight){return document.body.scrollHeight;}else{return document.body.offsetHeight;}}
//-------------------------------------------------------------------
function safetyEmail(name, domain, toplevel, mailto, subject){if(mailto==true){document.write('<a href="mailto:');document.write(name + '@' + domain + '.' + toplevel);if(subject.length > 0){document.write('?subject='+subject);}document.write('">');}document.write(name + '@' + domain + '.' + toplevel);if(mailto==true){document.write('</a>');}}
//-------------------------------------------------------------------
function frameExist(frame){if(typeof(eval("parent."+frame)) == 'object'){return true;}return false;}
//-------------------------------------------------------------------
function sleep(ms){var ctime = (new Date()).getTime();var stopTime = ctime+ms;while((new Date()).getTime()<stopTime){};}
//-------------------------------------------------------------------
function strPxToInt(s){if((typeof s) == "number"){s = s.toString();}s = s.replace(/px/,"");if(s.length == 0){s = "0";}i =  parseInt(s);return i;}
//-------------------------------------------------------------------
tmrMagicResize = null;magicX = 0;magicY = 0;magicResizeX = 0;magicResizeY = 0;magicObj = null;magicIncX = 0;magicIncY = 0;magicX_OK = false;magicY_OK = 0;function magicResizePanel(obj, px, py, stepX, stepY, delay){if(tmrMagicResize != null){window.clearInterval(tmrMagicResize);}if((typeof obj) == "string"){obj = getObj(obj);}magicObj = obj;magicResizeX = px;magicResizeY = py;magicX = strPxToInt(magicObj.style.width);magicY = strPxToInt(magicObj.style.height);if(isNaN(magicX) || isNaN(magicY)){fw_throw("function 'magicResizePanelpanel', position not set");return;}magicIncX = stepX;if(magicResizeX < magicX){magicIncX = -1*stepX;}magicIncY = stepY;if(magicResizeY < magicY){magicIncY = -1*stepY;}tmrMagicResize  = window.setInterval("magicResizePanelTmr()", delay);}
//----------------
function magicResizePanelTmr(){if((magicIncX < 0 && magicX > magicResizeX) || (magicIncX > 0 && magicX < magicResizeX)){magicX = magicX + magicIncX;magicObj.style.width = magicX;}else{magicX_OK = true;magicObj.style.width = magicResizeX;}if((magicIncY < 0 && magicY > magicResizeY) || (magicIncY > 0 && magicY < magicResizeY)){magicY = magicY + magicIncY;magicObj.style.height = magicY;}else{magicY_OK = true;magicObj.style.height = magicResizeY;}if(magicX_OK == true && magicY_OK == true){window.clearInterval(tmrMagicResize);}}
//-------------------------------------------------------------------
function setPanelPos(obj, px, py){if((typeof obj) == "string"){obj = getObj(obj);}var w = strPxToInt(obj.style.width);var h = strPxToInt(obj.style.height);if(isNaN(w) || isNaN(h)){fw_throw("function 'setPanelPos', panel position not set");return;}var x = 0;var y = 0;if((typeof px) == "number"){x = px;}else{if(w == 0 || h == 0){throw "setPanelPos: style width/height must beset";}if(px == "center"){x = Math.round((getDocWidth()/2)-(w/2));}else if(px == "left"){x = 1;}else if(px == "right"){x = Math.round((getDocWidth())-(w/2));}}if((typeof py) == "number"){y = py;}else{if(w == 0 || h == 0){throw "setPanelPos: style width/height must beset";}if(py == "middle"){y = Math.round((getDocHeight()/2)-(h/2));}else if(py == "top"){y = 1;}else if(py == "bottom"){y = Math.round((getDocHeight())-(h/2));}}if(x > -1){obj.style.left = x;}if(y > -1){obj.style.top = y;}return;}
//-------------------------------------------------------------------
function isDigit(val, additional_chars){var validchars = "1234567890";if(typeof(additional_chars) == "string"){validchars += additional_chars;}if(typeof(val) != "string"){val = String(val);}for(var i = 0; i < val.length; i++){if(validchars.indexOf(val.charAt(i)) == -1){return false;}}return true;}
//-------------------------------------------------------------------
function isNumber(val, additional_chars){if(typeof(additional_chars) == "string"){additional_chars += "+-.,";}else{additional_chars = "+-.,";}return isDigit(val, additional_chars);}
//-------------------------------------------------------------------
/*Sample:rounded("div#content","#FFF","#9DD4FF");roundedTop("div.news","#FFF","#91A7E3");rounded("form","#FFF","#BBD8FF");rounded("div#fw_IText","","#F4F4F4", "small");*/
// see getElementsBySelector()
function rounded(selector, bk, color, size){var i;var v=getElementsBySelector(selector);var l=v.length;for(i=0;i<l;i++){addTop(v[i],bk,color,size);addBottom(v[i],bk,color,size);}}
//-------------------------------------------------------------------

// see getElementsBySelector()
function roundedTop(selector,bk,color,size){var i;var v=getElementsBySelector(selector);for(i=0;i<v.length;i++)addTop(v[i],bk,color,size);}
//-------------------------------------------------------------------

// see getElementsBySelector()
function roundedBottom(selector,bk,color,size){var i;var v=getElementsBySelector(selector);for(i=0;i<v.length;i++)addBottom(v[i],bk,color,size);}
//-------------------------------------------------------------------
function addTop(el,bk,color,size){var i;var d=document.createElement("b");var cn="r";var lim=4;if(size && size=="small"){ cn="rs"; lim=2}d.className="rtop";d.style.backgroundColor=bk;for(i=1;i<=lim;i++){var x=document.createElement("b");x.className=cn + i;x.style.backgroundColor=color;d.appendChild(x);}el.insertBefore(d,el.firstChild);}
//-------------------------------------------------------------------
function addBottom(el,bk,color,size){var i;var d=document.createElement("b");var cn="r";var lim=4;if(size && size=="small"){ cn="rs"; lim=2}d.className="rbottom";d.style.backgroundColor=bk;for(i=lim;i>0;i--){var x=document.createElement("b");x.className=cn + i;x.style.backgroundColor=color;d.appendChild(x);}el.appendChild(d,el.firstChild);}
//-------------------------------------------------------------------
function getElementsBySelector(selector){var i;var s=[];var selid="";var selclass="";var tag=selector;var objlist=[];
	if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
s=selector.split(" ");var fs=s[0].split("#");if(fs.length==1) return(objlist);return(document.getElementById(fs[1]).getElementsByTagName(s[1]));}
	if(selector.indexOf("#")>0){ //id selector like "tag#id"
s=selector.split("#");tag=s[0];selid=s[1];}if(selid!=""){objlist.push(document.getElementById(selid));return(objlist);}
	if(selector.indexOf(".")>0){  //class selector like "tag.class"
s=selector.split(".");tag=s[0];selclass=s[1];}
	var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")return(v);for(i=0;i<v.length;i++){if(v[i].className==selclass){objlist.push(v[i]);}}return(objlist);}
//-------------------------------------------------------------------
function getFormData(lastdata, name_list, option, formname){if((typeof lastdata) != "string"){lastdata = "";}else if(lastdata.length > 0){if(lastdata.substr(lastdata.length-1,1) != "&"){lastdata += "&";}}if((typeof name_list) != "string"){name_list = "";}else{name_list = replaceAll(name_list,/\,/, ";");if(name_list.substr(name_list.length,1) != ";"){name_list += ";";}}if((typeof option) != "number"){option = 0;}if((typeof formname) != "string"){formname = '';}var parentobj = document;if(formname.length > 0){
      // -----------

      // for more than one form
formname = replaceAll(formname, /;/, ',');if(formname.indexOf(',') > -1){var lFormname = formname.split(",");var postdata = '';for(var i = 0; i < lFormname.length; i++){postdata += getFormData(lastdata, name_list, option, trim(lFormname[i]))+"&";}if(postdata.length > 0){postdata = postdata.substr(0, postdata.length-1);}return postdata;}
      // -----------

      // only objects of this form
parentobj = document.getElementById(formname);}var ldkeys = new Array();var ldvals = new Array();if(lastdata.substr(0,1) == "&"){lastdata = lastdata.substr(1,lastdata.length);}while(lastdata.length > 0){var pos = lastdata.indexOf("=");if(pos > -1){var name = lastdata.substr(0,pos);lastdata = lastdata.substr(pos+1);pos = lastdata.indexOf("&");if(pos > -1){var val = lastdata.substr(0,pos);lastdata = lastdata.substr(pos+1);ldkeys.push(name);ldvals.push(val);}}}var postdata = "";var v;var name;var val;v = parentobj.getElementsByTagName("input");for(var i=0;i<v.length;i++){name = v[i].name;type = v[i].type;val = v[i].value;if(name.length == 0){continue;}if(name_list.length > 0){var name_listArr = name_list.split(";");var inc = null;if(option == 0){inc = true;}else{inc = false;}for(var n = 0; n < name_listArr.length; n++){var needle = trim(name_listArr[n]);if(needle.length == 0){continue;}if(option == 0){
               if(name.indexOf(needle) > -1){ // exclude 
inc = false;break;}}else{
               if(name.indexOf(needle) > -1){ // include
inc = true;break;}}}if(!inc){continue;}}if(name.length > 0){if(type == "text" || type == "hidden" || type == "radio" || type == "checkbox" || type == "button" || type == "submit"){if(type == "radio"){if(postdata.indexOf(name) == -1){var e_list = document.getElementsByName(name);val = "";for(var r = 0; r < e_list.length; r++){if(e_list[r].checked == true){val = e_list[r].value;break;}}}else{continue;}}if(type == "checkbox"){if(v[i].checked != true){val = "";}}postdata += name+"="+escapeEx(val)+"&";while(true){var exist = ldkeys.search(name);if(exist == -1){break;}ldkeys.splice(exist,1);ldvals.splice(exist,1);}}
      } // if

   }// for
v = parentobj.getElementsByTagName("select");for(var i=0;i<v.length;i++){name = v[i].name;if(name.length == 0){continue;}if(name_list.length > 0){var name_listArr = name_list.split(";");var inc = null;if(option == 0){inc = true;}else{inc = false;}for(var n = 0; n < name_listArr.length; n++){var needle = trim(name_listArr[n]);if(needle.length == 0){continue;}if(option == 0){
               if(name.indexOf(needle) > -1){ // exclude 
inc = false;break;}}else{
               if(name.indexOf(needle) > -1){ // include
inc = true;break;}}}if(!inc){continue;}}
      if(name.indexOf("[") > -1){// multisel listbox
var o = v[i].options;for(var i2=0;i2<o.length;i2++){if(o[i2].selected){val = o[i2].value;postdata += name+"="+escapeEx(val)+"&";}}}else{val = v[i].value;postdata += name+"="+escapeEx(val)+"&";}while(true){var exist = ldkeys.search(name);if(exist == -1){break;}ldkeys.splice(exist,1);ldvals.splice(exist,1);}}v = parentobj.getElementsByTagName("textarea");for(var i=0;i<v.length;i++){name = v[i].name;val = v[i].value;if(name.length == 0){continue;}if(name_list.length > 0){var name_listArr = name_list.split(";");var inc = null;if(option == 0){inc = true;}else{inc = false;}for(var n = 0; n < name_listArr.length; n++){var needle = trim(name_listArr[n]);if(needle.length == 0){continue;}if(option == 0){
               if(name.indexOf(needle) > -1){ // exclude 
inc = false;break;}}else{
               if(name.indexOf(needle) > -1){ // include
inc = true;break;}}}if(!inc){continue;}}postdata += name+"="+escapeEx(val)+"&";var exist = ldkeys.search(name);if(exist > -1){ldkeys.splice(exist,1);ldvals.splice(exist,1);}}v = parentobj.getElementsByTagName("button");for(var i=0;i<v.length;i++){name = v[i].name;val = v[i].value;if(name.length == 0){continue;}if(name_list.length > 0){var name_listArr = name_list.split(";");var inc = null;if(option == 0){inc = true;}else{inc = false;}for(var n = 0; n < name_listArr.length; n++){var needle = trim(name_listArr[n]);if(needle.length == 0){continue;}if(option == 0){
               if(name.indexOf(needle) > -1){ // exclude 
inc = false;break;}}else{
               if(name.indexOf(needle) > -1){ // include
inc = true;break;}}}if(!inc){continue;}}postdata += name+"="+escapeEx(val)+"&";var exist = ldkeys.search(name);if(exist > -1){ldkeys.splice(exist,1);ldvals.splice(exist,1);}}lastdata = "";for(var i = 0; i < ldkeys.length; i++){name = ldkeys[i];val = ldvals[i];
      lastdata += name+"="+val+"&"; // attention, don't encode val 2 times
}lastdata = trim(lastdata);postdata = trim(postdata);postdata += lastdata;if(postdata.length > 0){postdata = postdata.substr(0,postdata.length-1);}
   //debugOut("postdata: "+postdata+"<br><br>"); 
return postdata;}
//-------------------------------------------------------------------
function formData2Fragment(s){if((typeof s) != "string"){s = getFormData();}s = replaceAll(s, /\=/, '^');s = replaceAll(s, /\&/, '/');return s;}
//-------------------------------------------------------------------
function setFormVal(name, val){var obj = document.getElementById(name);if(obj.nodeName == 'INPUT' || obj.nodeName == 'TEXTAREA' || obj.nodeName == 'SELECT'){if((typeof val) == 'string'){var p = val.indexOf("base64:");if(p > -1){val = val.substr(p+7, val.length);val = base64_decode(val);}}if(obj == null || (typeof obj) == 'undefined'){fw_throw('setFormVal: '+name+' is not found or not a html component object');return;}if(obj.type == 'radio' || obj.type == 'checkbox'){if((typeof val) != 'number' && (typeof val) != 'string' && ((typeof val) == 'object' && obj.type != 'checkbox') ){fw_throw('setFormVal: '+val+' is not a string/number ('+name+')');return;}var objs = document.getElementsByName(name);if((typeof val) == 'number'){objs[val].checked = true;}else if((typeof val) == 'object'){for(var i = 0; i < objs.length; i++){for(var j = 0; j < val.length; j++){if((typeof val[j]) == "number"){objs[j].checked = val[j];}else{if(trim(objs[i].value) == trim(val[j])){objs[i].checked = true;break;}else{objs[i].checked = false;}}}}
        }else{ // string
for(var i = 0; i < objs.length; i++){if(trim(objs[i].value) == trim(val)){objs[i].checked = true;}else{objs[i].checked = false;}}}}else if(obj.type == 'select-one' || obj.type == 'select-multiple'){if((typeof val) != 'object'){fw_throw('setFormVal: '+val+' is not an object');return;}var objs = obj.options;for(var i = 0; i < objs.length; i++){for(var j = 0; j < val.length; j++){if((typeof val[j]) == "number"){objs[j].selected = val[j];}else{if(trim(objs[i].value) == trim(val[j])){objs[i].selected = true;break;}else{objs[i].selected = false;}}}}}else{obj.value = val;}}else{replaceHtml(obj, val);}}
//-------------------------------------------------------------------
function ltrim(value) {var re = /\s*((\S+\s*)*)/;return value.replace(re, "$1");}
//-------------------------------------------------------------------
function rtrim(value) {var re = /((\s*\S+)*)\s*/;return value.replace(re, "$1");}
//-------------------------------------------------------------------
function trim(value){return ltrim(rtrim(value));}
//-------------------------------------------------------------------
function is_utf8(str){var c = 0;var b = 0;var bits = 0;var len = str.length;for(var i=0; i<len; i++){c=str.charCodeAt(i);if(c > 128){if((c >= 254)) return false;else if(c >= 252) bits=6;else if(c >= 248) bits=5;else if(c >= 240) bits=4;else if(c >= 224) bits=3;else if(c >= 192) bits=2;else return false;if((i+bits) > len) return false;while(bits > 1){i++;b=str.charCodeAt(i);if(b < 128 || b > 191) return false;bits--;}}}return true;}
//-------------------------------------------------------------------
function utf8_encode(s){s = s.replace(/\r\n/g,"\n");var utf = "";for(var n=0; n<s.length; n++){var c=s.charCodeAt(n);
        if(c<128){ // 1byte
utf += String.fromCharCode(c);
        }else if((c>127) && (c<2048)){ // 2byte
utf += String.fromCharCode((c>>6)|192);utf += String.fromCharCode((c&63)|128);
        }else{ // 3byte
utf += String.fromCharCode((c>>12)|224);utf += String.fromCharCode(((c>>6)&63)|128);utf += String.fromCharCode((c&63)|128);}}return utf;}
//-------------------------------------------------------------------
function utf8_decode(utf){var s = ""; var i=0; var c=c1=c2=0;while(i<utf.length){c = utf.charCodeAt(i);if(c<128){s += String.fromCharCode(c);i++;}else if((c>191) && (c<224)){c2 = utf.charCodeAt(i+1);s += String.fromCharCode(((c&31)<<6) | (c2&63));i+=2;}else{c2 = utf.charCodeAt(i+1); c3 = utf.charCodeAt(i+2);s += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));i+=3;}}return s;}
//-------------------------------------------------------------------
function utf8_fix($string){if(is_utf8($string))return $string;else return utf8_encode($string);}
//-------------------------------------------------------------------
function absLeft(el) {return (el.offsetParent != null)?el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;}
//-------------------------------------------------------------------
function absTop(el) {return (el.offsetParent != null)?el.offsetTop+absTop(el.offsetParent) : el.offsetTop;}
//-------------------------------------------------------------------
function getElementPos(el){var X = 0;var Y = 0;X = absLeft(el);Y = absTop(el);return {X : X, Y : Y};}
//-------------------------------------------------------------------
function realOffset(element){var Y = 0, X = 0;do {Y += element.scrollTop  || 0;X += element.scrollLeft || 0;element = element.parentNode;} while (element);return [X, Y];}
//-------------------------------------------------------------------
function cumulativeOffset(element){var Y = 0, X = 0;do {Y += element.offsetTop  || 0;X += element.offsetLeft || 0;element = element.offsetParent;} while (element);return [X, Y];}
//-------------------------------------------------------------------
function positionedOffset(element){var Y = 0, X = 0;do {Y += element.offsetTop  || 0;X += element.offsetLeft || 0;element = element.offsetParent;if (element) {if(element.tagName=='BODY') break;var p = Element.getStyle(element, 'position');if (p == 'relative' || p == 'absolute') break;}} while (element);return [X, Y];}
//-------------------------------------------------------------------
function offsetParent(element){if (element.offsetParent) return element.offsetParent;if (element == document.body) return element;while ((element = element.parentNode) && element != document.body)if (Element.getStyle(element, 'position') != 'static')return element;return document.body;}
//-------------------------------------------------------------------

// eventType => 'click', 'change', 'focus' ...
function sendMessage(obj, eventType){if((typeof obj) == "string"){obj = getObj(obj);}if(document.createEvent){var evt = document.createEvent("HTMLEvents");evt.initEvent(eventType, true, false);obj.dispatchEvent(evt);}else if(document.createEventObject){var evt = document.createEventObject();obj.fireEvent('on' + eventType, evt);}}
//-------------------------------------------------------------------
fw_utf8 = false;function escapeEx(s){if(fw_utf8 || is_utf8(s)){
     s = encodeURIComponent(s); // UTF-8 
if(s.indexOf("%u20AC") > -1){
		  s = replaceAll(s, /\%u20AC/, "%E2%82%AC"); // support for € char
}}else{
     s = escape(s);  // ISO/ASCII, see also php function "ajax_translate_special_char"   
if(s.indexOf("%u20AC") > -1){
		  s = replaceAll(s, /\%u20AC/, "%80"); // support for € char
}}if(s.indexOf("+") > -1){
		s = replaceAll(s, /\+/, "%2B"); // support for + char
}if(s.indexOf("'") > -1){
		s = replaceAll(s, /\'/, "%27"); // support for ' char
}return s;}
//-------------------------------------------------------------------
function blend(id, opacity) {transparency(id, opacity);}
//--------------
function transparency(id, transparency){var opacity = transparency;var object = getObj(id);try{object.style.opacity = (opacity / 100);object.style.MozOpacity = (opacity / 100);object.style.KhtmlOpacity = (opacity / 100);object.style.filter = "alpha(opacity=" + opacity + ")";}catch(e){}}
//-------------------------------------------------------------------
function countCheckedElements(s){var count = 0;try{var el = document.getElementsByName(s);for(var i = 0; i < el.length; i++){if(el[i].checked == true){count++;}}}catch(e){}return count;}
//--------------------------------------------------------------------
fw_DebugWin = null;function debugOut(msg, focus){try{if((typeof focus) != 'boolean'){focus = false;}msg = String(msg);cDate = new Date();var y = cDate.getFullYear().toString();var m = padL((cDate.getMonth()+1).toString(),"0",2);var d = padL(cDate.getDate().toString(),"0",2);var h = padL(cDate.getHours().toString(),"0",2);var i = padL(cDate.getMinutes().toString(),"0",2);var s = padL(cDate.getSeconds().toString(),"0",2);var ms = padL(cDate.getMilliseconds().toString(),"0",4);var cDate = y+"-"+m+"-"+d+" "+h+":"+i+":"+s+":"+ms;if(fw_DebugWin == null || ((typeof fw_DebugWin) == 'object' && fw_DebugWin.closed == true)){fw_DebugWin = window.open("", "crVCLJSDebugWin", "width=640,height=400,left=10,top=10,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,toolbar=no");fw_DebugWin.document.write("<head><title>crVCL Java Script Debug Window</title></head><b>crVCL Java Script Debug Window</b><br><br>");}fw_DebugWin.document.write(cDate+" - "+ msg +"<br>");fw_DebugWin.document.body.scrollTop = fw_DebugWin.document.body.scrollHeight;if(focus){window.focus();}}catch(e){}}
//--------------------------------------------------------------------
function isIE(returnVersion){var userAgent = navigator.userAgent.toLowerCase();var MSIEOffset = userAgent.indexOf("msie");if (document.all && MSIEOffset != -1){if((typeof returnVersion) == 'boolean' && returnVersion){return parseFloat(userAgent.substring(MSIEOffset + 5, userAgent.indexOf(";", MSIEOffset)));;}return true;}else {if((typeof returnVersion) == 'boolean' && returnVersion){return -1;}return false;}}
//--------------------------------------------------------------------
function replaceHtml(el, html) {var oldEl = el;if((typeof el) === "string"){oldEl = document.getElementById(el);}if(!isIE()){var newEl = oldEl.cloneNode(false);newEl.innerHTML = html;oldEl.parentNode.replaceChild(newEl, oldEl);
   }else{ // pure innerHTML is slightly faster in IE
oldEl.innerHTML = html;}}
//--------------------------------------------------------------------
function getParentWindow(setfocus){var hWin = null;if(opener){hWin = opener;}else if(parent){hWin = parent;}else{hWin = window;}if(setfocus==true){try{hWin.focus();}catch(e){}}return hWin;}
//--------------------------------------------------------------------------------------------------------------------------------------

// good to use with timeout like:   window.setTimeout("reloadAllImg()", 999);
function reloadAllImg(){var v = document.getElementsByTagName("img");for(var i=0;i<v.length;i++){var src = v[i].src;src = src.cut("?");var now = new Date();v[i].src = src+"?timestamp="+now.getTime();}}
//--------------------------------------------------------------------------------------------------------------------------------------
function writeCookie(name, value, min){if(min){var date = new Date();date.setTime(date.getTime() + (min*60*60*1000));var expires = "; expires=" + date.toGMTString();}else var expires = "";document.cookie = name + "=" + value + expires + "; path=/";}
//--------------------------------------------------------------------------------------------------------------------------------------
function readCookie(name){name = name + "=";var elements = document.cookie.split(';');for(var i = 0; i < elements.length; i++){var c = elements[i];while(c.charAt(0) == ' ') c = c.substring(1, c.length);if(c.indexOf(name) == 0) return c.substring(name.length, c.length);}return null;}
//--------------------------------------------------------------------------------------------------------------------------------------
function eraseCookie(name){writeCookie(name,"",-1);}
//--------------------------------------------------------------------------------------------------------------------------------------
var c64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');var l64 = {}, i, k;for(i=0; i<64; i++)l64[c64[i]] = i;
//--------------------------------------------------------------------------------------------------------------------------------------
function b64(s){var b=0, c, i, l=0, r='';for(i=0; i<s.length; i++) {c = s.charCodeAt(i) % 256;b = (b<<8) + c;l += 8;while (l >= 6)r += c64[(b>>(l-=6))%64];}if(l > 0)r += c64[((b%16)<<(6-l))%64];if(l != 0) while (l < 6)r += '=', l += 2;return r;}
//--------------------------------------------------------------------------------------------------------------------------------------
function bff(s) {var b=0, c, i, l=0, r='';for(i=0; i<s.length; i++) {c = l64[s.charAt(i)];if(isNaN(c))continue;b = (b<<6) + c;l += 6;while(l >= 8)r += String.fromCharCode((b>>>(l-=8))%256);}return r;}
//--------------------------------------------------------------------------------------------------------------------------------------
function base64_encode(s) {var r = '';for(var i=0; i<s.length; i+=54) {r += b64(s.substring(i, i+54)) + '\r\n';}return r;}
//--------------------------------------------------------------------------------------------------------------------------------------
function base64_decode(s) {var r = '';s = s.replace(/[^A-Za-z0-9+\/]+/g, '');for(var i=0; i<s.length; i+=72) {r += bff(s.substring(i, i+72));}return r;}
//--------------------------------------------------------------------------------------------------------------------------------------
function function_exists(funcName){try{if(typeof funcName == 'string' &&eval('typeof ' + funcName) == 'function'){return true;}return false;}catch(e){return false;}}
//--------------------------------------------------------------------------------------------------------------------------------------
function getStyle(obj, style_property){if((typeof obj) == "string"){obj = getObj(obj);}var style_result = "";try{style_result = eval('obj.style.'+style_property);}catch(e){fw_throw("can't read style property of object "+obj.id);}try{if(     (typeof style_result) == 'undefined' || ((typeof style_result) == 'string' && trim(style_result).length == 0)     ){var classname = '.'+obj.className;var classlist = document.styleSheets[0].rules || document.styleSheets[0].cssRules;for(var i=0; i<classlist.length; i++){if(classlist[i].selectorText == classname){style_result = eval('classlist[i].style.'+style_property);break;}}}}catch(e){fw_throw("can't read class style property of object ("+classname+") "+obj.id);}return style_result;}
//--------------------------------------------------------------------------------------------------------------------------------------
function is_firebug_present(){if(console.firebug)return true;return false;}
//--------------------------------------------------------------------------------------------------------------------------------------
function is_ssl(){var protocol = window.location.protocol;if(protocol == "https:"){return true;}return false;}
//--------------------------------------------------------------------------------------------------------------------------------------
function is_https(){return is_ssl();}
//--------------------------------------------------------------------------------------------------------------------------------------
function timestamp(){var now = new Date();return now.getTime();}
//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------
Array.prototype.search = function(value){for(var i = 0; i < this.length; i++){if(String(value) == String(this[i])){return i;}}return -1;};
//--------------------------------------------------------------------------------------------------------------------------------------
String.prototype.cut = function(neddle, inc_neddle){if((typeof inc_neddle) != "boolean"){inc_needle = false;}var pos = -1;var s = this;if((pos = this.indexOf(neddle)) > -1){if(inc_neddle){ pos += needle.length; }s = s.substr(0,pos);}return s;}
//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------
fw_last_window_width = 0;fw_last_window_height = 0;fw_div_window_width = 0;fw_div_window_height = 0;fw_last_doc_width = 0;fw_last_doc_height = 0;fw_div_doc_width = 0;fw_div_doc_height = 0;
//---------------------------------
function fw_doc_init(){if(document.captureEvents){document.captureEvents(Event.KEYPRESS | Event.KEYUP | Event.KEYDOWN);}document.onkeypress = fw_setKeyCode;
	////////////////

	// not tested change, delete next 2 line if not work
document.onkeydown = fw_setKeyCode;document.onkeyup = fw_setKeyCode;
	////////////////
if(document.captureEvents){document.captureEvents(Event.MOUSEMOVE);}document.onmousemove = fw_getMousePos;}
//---------------------------------
function fw_isPageLoaded(b){if((typeof b) == "boolean"){if(b){getObj("fwPageLoaded").value = "true";}else{getObj("fwPageLoaded").value = "false";}}try{if(getObj("fwPageLoaded").value == "true"){return true;}}catch(e){}return false;}
//---------------------------------
function fw_doc_resize(){fw_diff_window_width = getWindowWidth()-fw_last_window_width;fw_diff_window_height = getWindowHeight()-fw_last_window_height;fw_last_window_width = getWindowWidth();fw_last_window_height = getWindowHeight();fw_diff_doc_width = getDocWidth()-fw_last_doc_width;fw_diff_doc_height = getDocHeight()-fw_last_doc_height;fw_last_doc_width = getDocWidth();fw_last_doc_height = getDocHeight();if((typeof fw_doc_onresize_js) == "string"){eval(fw_doc_onresize_js);}}
//---------------------------------
fw_sleep_start = 0;function fw_sleep(ms){if(fw_sleep_start == 0){fw_sleep_start = new Date();}while(true){var ctime = new Date();if(ctime.getTime() - fw_sleep_start.getTime() > ms){fw_sleep_start = 0;break;}}}
//---------------------------------
fw_mouse_x = 0;fw_mouse_y = 0;function fw_getMousePos(e){if(typeof(e) != "object"){return;}var X;var Y;/*
  // old version DOM 1
if(document.all){X = event.clientX + document.body.scrollLeft;Y = event.clientY + document.body.scrollTop;}else{if(e.clientX){X = e.clientX;Y = e.clientY;}else{X = e.pageX;Y = e.pageY;}}*/
  // new version DOM 2 and AJAX conform
if(e.pageX){X = e.pageX;Y = e.pageY;} else if(window.event && window.event.clientX) {var isStrictMode = document.compatMode && document.compatMode != 'BackCompat' ? true : false;var scrollX = isStrictMode ? document.documentElement.scrollLeft : document.body.scrollLeft;var scrollY = isStrictMode ? document.documentElement.scrollTop : document.body.scrollTop;X = window.event.clientX + scrollX;Y = window.event.clientY + scrollY;}
	// for debug

   //window.location.hash = ( "mouse:"+(X.toString()+"/"+Y.toString())  );

   //window.location.hash = ( "mouse:"+(X.toString()+"/"+Y.toString())  );
if(X < 0){X = 0;}if(Y < 0){Y = 0;}if(X > 0){fw_mouse_x = X;}if(Y > 0){fw_mouse_y = Y;}return {X:fw_mouse_x,Y:fw_mouse_y};}
//---------------------------------
fw_tooltip_timer = null;function fw_showTooltip(msg){if(fw_tooltip_delay == 0){fw_tooltip_delay = 1;}if(fw_tooltip_delay == '#tooltipdelay#'){fw_tooltip_delay = 3;}if(!msg){return;}if(fw_tooltip_timer == null){fw_tooltip_timer = window.setTimeout("fw_showTooltip('"+msg+"')", fw_tooltip_delay*998);return;}hlp = document.getElementById("fw_Tooltip");
   // new version support linefeed
var container = document.createElement("div");hlp.replaceChild(container,hlp.firstChild);var lines = msg.split("\n");for(var i = 0; i < lines.length; i++){container.appendChild(document.createTextNode(lines[i]));container.appendChild(document.createElement("br"));}
   // version without linefeed

   // hlp.firstChild.nodeValue = container;
hlp.style.top = fw_mouse_y-30;hlp.style.left = fw_mouse_x+5;var cur_left = hlp.style.left;cur_left = cur_left.replace(/px/, "");if(document.body.clientWidth){if(fw_mouse_x+180 > document.body.clientWidth){hlp.style.left = cur_left-180;}}else if(window.innerWidth){if(fw_mouse_x+180 > window.innerWidth){hlp.style.left = cur_left-180;}}hlp.style.visibility = "visible";if(fw_tooltip_timer){window.clearTimeout(fw_tooltip_timer);fw_tooltip_timer = null;}}
//---------------------------------
function fw_hideTooltip(){if(fw_tooltip_timer){window.clearTimeout(fw_tooltip_timer);fw_tooltip_timer = null;}document.getElementById("fw_Tooltip").style.visibility = "hidden";}
//---------------------------------
fw_itext_timer = null;function fw_showIText(msg){if(!msg){return;}hlp = document.getElementById("fw_IText");hlp_caption = document.getElementById("fw_IText_Caption");if(hlp_caption.firstChild.nodeValue != msg){fw_hideIText2();}if(fw_itext_timer){return;}if(hlp.style.visibility == "visible"){return true;}hlp_caption.innerHTML = msg;hlp.style.top = fw_mouse_y-50;hlp.style.left = fw_mouse_x+5;var cur_left = hlp.style.left;cur_left = cur_left.replace(/px/, "");if(document.body.clientWidth){if(fw_mouse_x+100 > document.body.clientWidth){hlp.style.left = cur_left-180;}}else if(window.innerWidth){if(fw_mouse_x+100 > window.innerWidth){hlp.style.left = cur_left-180;}}hlp.style.visibility = "visible";}
//---------------------------------
function fw_hideIText(){if(fw_itext_timer == null){fw_itext_timer = window.setTimeout("fw_hideIText2()", 5*998);return;}}
//---------------------------------
function fw_hideIText2(){if(fw_itext_timer){window.clearTimeout(fw_itext_timer);fw_itext_timer = null;}if(document.getElementById("fw_IText").style.backgroundColor != ""){return;}document.getElementById("fw_IText").style.visibility = "hidden";}
//---------------------------------
function fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var MonthList;if(typ == "de"){MonthList = new Array("Januar", "Februar", "März", "April", "Mai", "Juni","Juli", "August", "September", "Oktober", "November", "Dezember");}else{MonthList = new Array("January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December");}var dCurDate = new Date();var dCalDate = new Date();if(date.length == 10 && date.charAt(4) == "-" && date.charAt(7) == "-"){var y = date.substr(0,4);var m = date.substr(5,2);var d = date.substr(8,2);m--;dCalDate = new Date(y,m,d);}var dFirstDateOfMonth = new Date(dCalDate.getFullYear(), dCalDate.getMonth(), 1);var startCell = 0;if(dFirstDateOfMonth.getDay() == 0){startCell = 6;}else{startCell = dFirstDateOfMonth.getDay()-1;}var dStartDate = new Date(dCalDate.getFullYear(), dCalDate.getMonth(), 1);dStartDate.setDate(1-startCell);for(var i = 0; i < 42; i++){var xstyle = "";var calcell = document.getElementById(objname+"_cell"+i.toString());var color = fontcolor;if(dateToMySQLDate(dCurDate) == dateToMySQLDate(dStartDate)){
          color = todaycolor; // mark today
xstyle = "font-weight:bold;"}var day = dStartDate.getDate().toString();if(day.length == 1){day = "&nbsp;"+day+"&nbsp;";}var acell_type = "";if(dCurDate.getMonth() != dStartDate.getMonth()){acell_type = "1";}else{acell_type = "2";}var y = dStartDate.getFullYear().toString();var m = padL((dStartDate.getMonth()+1).toString(),"0",2);var d = padL(dStartDate.getDate().toString(),"0",2);var sDate = y+"-"+m+"-"+d;var onClick  = "";onClick += "for(var i = 0; i < 42; i++){var cell = document.getElementById('"+objname+"_acell1'+i.toString());if(cell){cell.style.background='"+bgcolor+"';}}";onClick += "for(var i = 0; i < 42; i++){var cell = document.getElementById('"+objname+"_acell2'+i.toString());if(cell){cell.style.background='"+monthcolor+"';}}";onClick += "this.style.background='"+markcolor+"';";onClick += "document.getElementById('"+objname+"_date').value = '"+sDate+"';";var cellval = "<a id=\""+objname+"_acell"+acell_type+i.toString()+"\" onClick=\""+onClick+"\" style=\"text-decoration:none;color:"+color+";"+xstyle+"\" href=\"javascript:if(true){}\">"+day+"</a>";calcell.innerHTML = cellval;var xcell = document.getElementById(objname+"_acell"+acell_type+i.toString());if(dCurDate.getMonth() != dStartDate.getMonth() || dCurDate.getFullYear() != dStartDate.getFullYear()){calcell.style.background=bgcolor;}else{calcell.style.background=monthcolor;}if(dateToMySQLDate(dStartDate) == dateToMySQLDate(dCalDate)){
          xcell.style.background=markcolor; // mark calendar set date
}dStartDate.setDate(dStartDate.getDate()+1);}var month_year_div = document.getElementById(objname+"_month_year");month_year_div.innerHTML = MonthList[dCalDate.getMonth()]+", "+dCalDate.getFullYear().toString();var sDate = dateToMySQLDate(dCalDate);var date_field = document.getElementById(objname+"_date");date_field.value = sDate;}
//---------------------------------
function fw_TodayCalendar(objname, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var dCurDate = new Date();var date = dateToMySQLDate(dCurDate);fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor);}
//---------------------------------
function fw_MonthBackCalendar(objname, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var sCalDate = document.getElementById(objname+"_date").value;var y = sCalDate.substr(0,4);var m = sCalDate.substr(5,2);var d = sCalDate.substr(8,2);m--;var dCalDate = new Date(y, m-1, d);var x = 31;while(dCalDate.getMonth() == m){if(m-1 < 0){m=12;y--;}dCalDate = new Date(y, m-1, x);x--;}var date = dateToMySQLDate(dCalDate);fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor);}
//---------------------------------
function fw_MonthForwardCalendar(objname, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var sCalDate = document.getElementById(objname+"_date").value;var y = sCalDate.substr(0,4);var m = sCalDate.substr(5,2);var d = sCalDate.substr(8,2);if(m == 12){m=0;y++;}var dCalDate = new Date(y, m, d);var date = dateToMySQLDate(dCalDate);fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor);}
//---------------------------------
function fw_YearBackCalendar(objname, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var sCalDate = document.getElementById(objname+"_date").value;var y = sCalDate.substr(0,4);var m = sCalDate.substr(5,2);var d = sCalDate.substr(8,2);m--;var dCalDate = new Date(y-1,m,d);var date = dateToMySQLDate(dCalDate);fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor);}
//---------------------------------
function fw_YearForwardCalendar(objname, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor){var sCalDate = document.getElementById(objname+"_date").value;var y = sCalDate.substr(0,4);var m = sCalDate.substr(5,2);var d = sCalDate.substr(8,2);m--;y++;var dCalDate = new Date(y,m,d);var date = dateToMySQLDate(dCalDate);fw_drawCalendar(objname, date, typ, bgcolor, fontcolor, markcolor, todaycolor, monthcolor);}
//---------------------------------
function getNamedKey(k){if((typeof KeyEvent) == "undefined"){return '';}else{for(key in KeyEvent){if(KeyEvent[key] == k){return key.substr("DOM_VK_".length);}}}}
//---------------------------------
fw_keyCode = 0;fw_keyChr = "";fw_keyAlt = false;fw_keyCtrl = false;fw_keyShift = false;function fw_setKeyCode(eEvent){var e = eEvent || window.event;var namedKey = false;if(!e){fw_keyAlt = false;fw_keyCtrl = false;fw_keyShift = false;fw_keyCode = 0;fw_keyChr = "";return;}if(document.layers){fw_keyAlt = (e.modifiers==Event.ALT_MASK);fw_keyCtrl = (e.modifiers==Event.CONTROL_MASK);fw_keyShift = (e.modifiers==Event.SHIFT_MASK);fw_keyCode = e.which;}else if(document.all){fw_keyAlt = e.altKey;fw_keyCtrl = e.ctrlKey;fw_keyShift = e.shiftKey;fw_keyCode = e.keyCode;} else if (document.getElementById){fw_keyAlt = e.altKey;fw_keyCtrl = e.ctrlKey;fw_keyShift = e.shiftKey;if(e.charCode>0){fw_keyCode = e.charCode;}if(e.which>0){fw_keyCode = e.which;}if(e.keyCode>0){fw_keyCode = e.keyCode;namedKey = true;}}else{fw_keyAlt = false;fw_keyCtrl = false;fw_keyShift = false;fw_keyCode = 0;fw_keyChr = "";}if(fw_keyCode != 0){if(namedKey){fw_keyChr = getNamedKey(fw_keyCode);}else{fw_keyChr = String.fromCharCode(fw_keyCode);}}}
//---------------------------------
function fw_mask(evt, obj, mask){var IsValidChar = true;fw_setKeyCode(evt);if((typeof obj) == "string"){obj = document.getElementsByName(obj);}if(fw_keyCode < 32) return true;if(fw_keyChr == ""){return true;}
	if(fw_keyChr.length > 1){ // LEFT, RIGHT, HOME, END, DEL
return true;}
	if(fw_keyCtrl){return true;} // Ctrl+X, Ctrl+C, Ctrl+V
var isGEKO = false;var range = null;var start = 0;var end = 0;if((typeof obj.selectionStart) != 'undefined'){start = obj.selectionStart;end = obj.selectionEnd;isGEKO = true;}else{range = document.selection.createRange();range.moveStart('textedit', -1);start = range.text.length;}var val = obj.value;var oldval = obj.value;if(mask == "##.##.####"){if(!isDigit(fw_keyChr,".")){IsValidChar = false;}else{if(val.length == 3 && val.substr(2,1) != "."){val = val.substr(0,2)+"."+val.substr(2,1);}else if(val.length == 6 && val.substr(5,1) != "."){val = val.substr(0,5)+"."+val.substr(5,1);}else if(val.length == 10 && (val.substr(2,1) != "." || val.substr(5,1) != ".")){val = val.substr(0,2)+"."+val.substr(3,2)+"."+val.substr(6,4);}val = replaceAll(val,/\.\./, ".");end++;}}else if(mask == "####-##-##"){if(!isDigit(fw_keyChr,"-")){IsValidChar = false;}else{if(val.length == 5 && val.substr(4,1) != "-"){val = val.substr(0,4)+"-"+val.substr(4,1);}else if(val.length == 8 && val.substr(7,1) != "-"){val = val.substr(0,7)+"-"+val.substr(7,1);}else if(val.length == 10 && (val.substr(4,1) != "-" || val.substr(7,1) != "-")){val = val.substr(0,4)+"-"+val.substr(6,2)+"-"+val.substr(8,2);}val = replaceAll(val,/\-\-/, "-");end++;}}else if(mask == "##:##:##"){if(!isDigit(fw_keyChr,":")){IsValidChar = false;}else{if(val.length == 3 && val.substr(2,1) != ":"){val = val.substr(0,2)+":"+val.substr(2,1);}else if(val.length == 6 && val.substr(5,1) != ":"){val = val.substr(0,5)+":"+val.substr(5,1);}else if(val.length == 8 && (val.substr(2,1) != ":" || val.substr(5,1) != ":")){val = val.substr(0,2)+":"+val.substr(3,2)+":"+val.substr(6,2);}val = replaceAll(val,/\:\:/, ":");end++;}}else if(mask == "#"){if(!isDigit(fw_keyChr)){IsValidChar = false;}}else if(mask == "-#"){if(!isDigit(fw_keyChr,"-")){IsValidChar = false;}else{var minus = "";if(val.substr(0,1) == "-"){minus = "-";}val = replaceAll(val,/\-/, "");val = minus + val;}}else if(mask.indexOf("#.###,") > -1){if(!isNumber(fw_keyChr)){IsValidChar = false;}else{
			// override the normal funktion of inputfield
IsValidChar = false;val = val.substr(0,start)+fw_keyChr+val.substr(start,val.length);if(isGEKO){start++;end++;}
			// start with mask
var maxdecpoints = 0;try{maxdecpoints = (mask.substr(mask.indexOf(",")+1,mask.length)).length;}catch(e){maxdecpoints = 0;}val = replaceAll(val,/\.\./, ".");val = replaceAll(val,/\,\,/, ",");var sign = "";if(val.substr(0,1) == "-"){sign = "-";}if(val.substr(0,1) == "+"){sign = "+";}val = replaceAll(val,/\-/, "");val = replaceAll(val,/\+/, "");val = sign + val;var comma = val.search(/\,/);var digits = "";if(comma > -1){digits = val.substr(comma+1,val.length);val = val.substr(0,comma);}if(comma > -1 && maxdecpoints > 0){val = val +","+ digits;}if(digits.length > maxdecpoints){val = oldval;start--;end--;}}}else if(mask == "#.##" || mask == "#,##"){if(!isDigit(fw_keyChr,",.")){IsValidChar = false;}else{val = val.replace(/\.\./, ".");val = val.replace(/\,\,/, ",");}}obj.value = val;obj.focus();if(isGEKO){obj.selectionStart = start;obj.selectionEnd = end;}else{range.move('character',start+1);range.select();}return IsValidChar;}
//--------------------------------------------------------------------
function fw_ModalWinFocus(myWindow, intervall){try{if(myWindow.closed){window.clearInterval(intervall);return;}myWindow.focus();}catch(everything){}}
//--------------------------------------------------------------------

// for onmouseover and onmouse used by php class html_Table
function fw_setTableRowColor(tablename, row, colcount, color, type){if(row < 0 || colcount < 0){return;}if(typeof(color) == 'undefined'){color = "";}if(typeof(type) == 'undefined'){type = "";}if(type.search(/click/) != -1){var cfield = getObj(tablename+"_highlight_row");var lastrow = cfield.value;if(lastrow == row){return;}if(lastrow != ""){fw_setTableRowColor(tablename, lastrow, colcount);}}for(var i = 0; i < colcount; i++){if(color == ''){var cfield = getObj(tablename+"_cellcolor_"+i+"_"+row);if(cfield){color = cfield.value;}}var cell = getObj(tablename+"_"+i+"_"+row);if(cell){cell.style.backgroundColor = color;}}var cfield = getObj(tablename+"_highlight_row");cfield.value = row;}
//--------------------------------------------------------------------
function crVCLException(msg, number){if(typeof(number) != 'number'){this.number = number;}this.description = "crVCL internal error";this.message = msg;this.name = "crVCLException";this.toString = function(){var errornum = '';if(typeof(number) == 'number'){errornum = ' ('+parseInt(number)+')';}return this.name + ': ' + this.message + errornum;}}crVCLException.prototype = new Error();
//--------------------------------------------------------------------
function fw_throw(msg, number){var ex = new crVCLException(msg, number);throw ex;}
//---------------------------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------------------------
/*readyState(s)0 = uninitialized  ( before open() )1 = loading2 = loaded3 = interactive4 = complete*//*request types*/REQUEST_HEAD = 0;REQUEST_GET  = 1;REQUEST_POST = 2;REQUEST_XML  = 3;var fw_AjaxHandler = 1;function fwAjaxHandler(){var _m_pipes = new Array();var _m_hist_id = new Array();var _m_hist_req = new Array();var _m_trace = false;var _m_hTrace = null;var _m_last_hist_id = null;var _m_last_request_time = null;
//--------------------------------------------------------------------      
this.writetrace = writetrace = function(msg){try{if(_m_trace == true && msg.length > 0){var cDate = new Date();var y = cDate.getFullYear().toString();var m = padL((cDate.getMonth()+1).toString(),"0",2);var d = padL(cDate.getDate().toString(),"0",2);var h = padL(cDate.getHours().toString(),"0",2);var i = padL(cDate.getMinutes().toString(),"0",2);var s = padL(cDate.getSeconds().toString(),"0",2);var ms = padL(cDate.getMilliseconds().toString(),"0",4);var cDate = y+"-"+m+"-"+d+" "+h+":"+i+":"+s+":"+ms;if(_m_hTrace == null || ((typeof _m_hTrace) == 'object' && _m_hTrace.closed == true)){_m_hTrace = window.open("", "crVCLAjaxTraceWin", "width=640,height=400,left=10,top=10,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,toolbar=no");_m_hTrace.document.write("<head><title>crVCL Ajax Trace Window</title></head><b>crVCL Ajax Trace Window</b>");}if(msg.indexOf("init") > -1){_m_hTrace.document.write("<br><br>");}_m_hTrace.document.write(cDate+" - "+ msg +"<br>");_m_hTrace.document.body.scrollTop = _m_hTrace.document.body.scrollHeight;}}catch(e){}}
//--------------------------------------------------------------------   
this.openPipes = function(){return _m_pipes.length;}
//--------------------------------------------------------------------   
this.enableTrace = function(b){_m_trace = b;}
//--------------------------------------------------------------------          
function _openPipe(id){if(id >= _m_pipes.length){_m_pipes.push(null);}if(_m_pipes[id] != null){return;}try{
           if(window.XMLHttpRequest){ // IE7, Mozilla, Opera and Safari
_m_pipes[id] = new XMLHttpRequest();this.writetrace("id:"+id+", init XMLHttpRequest");
           }else if(window.ActiveXObject){ //  < IE7

               for(var i = 6; i; i--){ // try load msxml dll version
try{
                       if(i == 1){ // load old version
_m_pipes[id] = new ActiveXObject("Microsoft.XMLHTTP");this.writetrace("id:"+id+", init Microsoft.XMLHTTP");}else if(i == 2){_m_pipes[id] = new ActiveXObject("Msxml2.XMLHTTP");this.writetrace("id:"+id+", init Msxml2.XMLHTTP");}else{_m_pipes[id] = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0");this.writetrace("id:"+id+", init Msxml2.XMLHTTP." + i + ".0");}}catch(e){_m_pipes[id] = null;}if(_m_pipes[id] != null){break;}}}}catch(e){_m_pipes[id] = null;fw_throw("error open pipe for ajax id ("+id.toString()+")");}}
//--------------------------------------------------------------------   
this.request = function(id, source, data, callback, type, wait, async){if(!data){data = '';}if(!callback){callback = "";}if(isNaN(type)){type = 1;}if(isNaN(wait)){wait = 0;}if(isNaN(async)){async = false;}if(source.length == 0){fw_throw("no ajax request page is set ("+id.toString()+")");return false;}pfrag = source.indexOf('#');
      if(pfrag != -1){         // not send the fragment with the http request, fragments should be used only for client side
source = source.substr(0, pfrag);}pfrag = data.indexOf('#');
      if(pfrag != -1){         // not send the fragment with the http request, fragments should be used only for client side
data = data.substr(0, pfrag);}if(!async){window.document.body.style.cursor = 'progress';window.setTimeout("eval(\"window.document.body.style.cursor = 'auto';\", 1500)");}var protocol = window.location.protocol;if(protocol == "https:"){source = source.replace(/http\:/, "https:");}else if(protocol == "http:"){source = source.replace(/https\:/, "http:");}
      // wait if a synchron request is not finished (not for zombie requests)
var now = new Date();if(!async && wait < 1&& _m_pipes[id] != null && _m_pipes[id].readyState > 0 && _m_pipes[id].readyState < 4&& _m_last_request_time + 10000 > now.getTime()){wait = 999;}
      // wait for init. of ajax
if(wait != -1 && (wait > 0 || fw_isPageLoaded() == false || !function_exists(callback))){if((fw_isPageLoaded() == false || !function_exists(callback)) && wait == 0){wait=1500;}window.setTimeout("eval(\"fw_AjaxHandler.request('"+id.toString()+"', '"+source+"', '"+data+"', '"+callback+"', "+type.toString()+", -1, "+async+")\")", wait);return false;}
      _openPipe(id); // if not exist

      // previous request not finished, abort it before sending a new request
if(_m_pipes[id] != null && _m_pipes[id].readyState > 0 && _m_pipes[id].readyState < 4){_m_pipes[id].abort();}if(type == 1 || type == 2){var now = new Date();if(data.length > 0){data = utf8_fix('&'+data);}data = 'request_timestamp='+now.getTime()+data;}try{switch(type){
   			case 0: // HEAD
_m_pipes[id].open("HEAD", source, async);data = null;this.writetrace("id:"+id+", open HEAD "+source);break;
   			case 2: // POST
data = data;_m_pipes[id].open("POST", source, async);_m_pipes[id].setRequestHeader('Expires', 'Mon, 26 Jul 1970, 00:00:00 GMT');_m_pipes[id].setRequestHeader('Cache-Control', 'no-store, no-cache, max-age=0, must-revalidate, post-check=0, pre-check=0');_m_pipes[id].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');if(_m_pipes[id].overrideMimeType)_m_pipes[id].overrideMimeType('text/html; UTF-8;');if(data.length > 1024*4){_m_pipes[id].setRequestHeader('Content-Encoding', 'gzip, deflate');}else{_m_pipes[id].setRequestHeader('Content-Encoding', 'None');}_m_pipes[id].setRequestHeader('Content-Length', data.length);this.writetrace("id:"+id+", open POST "+source);break;
   			case 3: // XML
data = "xml=" + data;
   			default: // 1 => GET 
var file = source;if(data.length > 0){file += "?"+data;}_m_pipes[id].open("GET", file, async);_m_pipes[id].setRequestHeader('Expires', 'Mon, 26 Jul 1970, 00:00:00 GMT');_m_pipes[id].setRequestHeader('Cache-Control', 'no-store, no-cache, max-age=0, must-revalidate, post-check=0, pre-check=0');_m_pipes[id].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');if(_m_pipes[id].overrideMimeType)_m_pipes[id].overrideMimeType('text/html; UTF-8;');_m_pipes[id].setRequestHeader('Content-Encoding', 'None');data = null;this.writetrace("id:"+id+", open GET "+file);}}catch(e){fw_throw("error open ajax request");return false;}if(async && callback.length > 0){try{
   	     _m_pipes[id].onreadystatechange = eval(callback); // only function name, parameters not allowed
}catch(e){fw_throw(e.message+" or ajax callback ("+callback+") not registered");}}var now = new Date();_m_last_request_time = now.getTime();
       // send request to server
try{_m_pipes[id].send(data);this.writetrace("id:"+id+", send "+source);}catch(e){fw_throw("error send ajax request");return false;}
   	// set global key events back, because IE remain the last key state after ajax request
fw_keyCode = 0;fw_keyChr = "";fw_keyAlt = false;fw_keyCtrl = false;fw_keyShift = false;if(!async && callback.length > 0){try{
   	     eval(callback+"();"); // only function name, parameters not allowed
}catch(e){fw_throw(e.message+" or ajax callback ("+callback+") not registered");}}return true;}
//--------------------------------------------------------------------   
this.getPipe = function(id){try{return _m_pipes[id];}catch(e){return null;}}
//--------------------------------------------------------------------   
this.getHeader = function(id, name){try{return _m_pipes[id].getResponseHeader(name);}catch(e){return null;}}
//--------------------------------------------------------------------   
this.getAnswer = function(id){try{return _m_pipes[id].responseText;}catch(e){return null;}}
//--------------------------------------------------------------------   
this.getStatus = function(id){try{return _m_pipes[id].status;}catch(e){return null;}}
//--------------------------------------------------------------------   
this.getStatusText = function(id){try{return _m_pipes[id].statusText;}catch(e){return null;}}
//--------------------------------------------------------------------   
this.getReadyState = function(id){try{return _m_pipes[id].readyState;}catch(e){return null;}}
//--------------------------------------------------------------------      
this.abort = function(id){return _m_pipes[id].abort();}
//--------------------------------------------------------------------      
this.parseJSfromAnswer = function(id){var responseText = _m_pipes[id].responseText;var code = "";responseText = replaceAll(responseText, /\<SCRIPT/, "<script");responseText = replaceAll(responseText, /\<\/SCRIPT/, "</script");while(responseText.length > 0){var p = responseText.indexOf("\<script");if(p > -1){responseText = responseText.substring(p, responseText.length);p = responseText.indexOf("\>");if(p > -1){responseText = responseText.substring(p+1, responseText.length);p = responseText.indexOf("\<\/script\>");if(p > -1){code += responseText.substr(0, p);responseText = responseText.substring(p+9, responseText.length);}else{break;}}else{break;}}else{break;}}if(code.length == 0){return false;}var ret = null;var p = -1;while(true){p = code.indexOf("\<\!\-\-");if(p == -1){break;}var tmp = code.substring(0, p);code = code.substring(p+4);p = code.indexOf("\/\/\-\-\>");if(p > -1){code = code.substring(p+5);}code = tmp + code;}var emsg = '';
      try{ // remove fw_AjaxParseJS comment to execute the script
var c1 = "\\/\\*fw_AjaxParseJS ";var c2 = " fw_AjaxParseJS\\*\\/";code = replaceAll(code, new RegExp(c1), "");code = replaceAll(code, new RegExp(c2), "");ret = eval(code);}catch(e){emsg = "AjaxParseJS Error\n\n"+e.name+" - "+e.message+"\n\n"+code.substr(0,400)+"\n\n.....";if(fw_debug){
            alert(emsg); // needfully to debug in some firebug versions, because they not alert each exception
}fw_throw(emsg);}return ret;}
//--------------------------------------------------------------------            
}
//--------------------------------------------------------------------            
fw_AjaxHistHandler = 1;function fwAjaxHistHandler(){_m_histIds = new Array();_m_histReqs = new Array();_m_last_hist_id = "";
//--------------------------------------------------------------------                     
this.concatFragment = function(fragment, source, data){if(!fragment){fragment = '';}var pfrag = source.indexOf('#');if(pfrag != -1){var sfrag = source.substr(pfrag+1, source.length);if(data.indexOf('#') != -1){data += "/"+sfrag;}else{data += "#"+sfrag;}}var pfrag = data.indexOf('#');if(pfrag != -1){if(fragment.length > 0){fragment += '/';}fragment += data.substr(pfrag+1, data.length);}return fragment;}
//--------------------------------------------------------------------                  
this.save = function(id, source, data, callback, type, wait, async){
      if(_m_histIds.length > 20){// do not fuck the memory
_m_histIds.reverse();_m_histIds.pop();_m_histIds.reverse();_m_histReqs.reverse();_m_histReqs.pop();_m_histReqs.reverse();}var now = new Date();var histid = now.getFullYear().toString(10)+now.getMonth().toString(10)+now.getDay().toString(10)+now.getHours().toString(10)+now.getMinutes().toString(10)+now.getSeconds().toString(10)+now.getMilliseconds().toString(10);var fragment = fw_ajax_hist_id_fragment_name+'^'+histid;fragment = this.concatFragment(fragment, source, data);
      window.location.hash = fragment; // don´t change the order      

      _m_last_hist_id = histid;        // of the next lines
_m_histIds.push(histid);var sub1 = escape("fw_AjaxHandler.request("+id.toString()+", '"+source+"', '");var sub2 = "', '"+callback+"', "+type.toString()+", "+wait.toString()+", "+(new Boolean(async).toString())+");";_m_histReqs.push(sub1+data+sub2);var IEver = isIE(true);
	   //if(IEver > 0 && IEver < 8){ //    < IE8	      

	   if(IEver > 0){   // is IE
var IE_fragment = replaceAll(fragment, /\=/, '^');IE_fragment = replaceAll(IE_fragment, /\&/, '/');getObj('AjaxHistoryHandleFrame').src = 'blank.html?'+IE_fragment;}}
//--------------------------------------------------------------------               

   // called von html_Doc to request drawbacks
this.guard = function(){var hash = "";var IEver = isIE(true);
   	  //if(IEver == -1 || IEver > 7) //    >= IE8 and all other browser

   	  if(IEver == -1) //    All other browser
{hash = window.location.hash;if(hash.length > 0){hash = hash.substr(1, hash.length);}}else{var oIFrmDoc = null;try{var oIfrm = document.getElementById('AjaxHistoryHandleFrame');if(oIfrm.contentDocument) {oIFrmDoc = oIfrm.contentDocument;}else if(oIfrm.contentWindow){oIFrmDoc = oIfrm.contentWindow.document;}else if(oIfrm.document){oIFrmDoc = oIfrm.document;}}catch(e){oIFrmDoc = null;}if(oIFrmDoc != null){hash = String(oIFrmDoc.location);}var pos = hash.indexOf("?");hash = hash.substr(pos+1, hash.length);hash = replaceAll(hash, /\=/, '^');hash = replaceAll(hash, /\&/, '/');var last_hash = window.location.hash;last_hash = replaceAll(last_hash, /\#/, '');if(hash.indexOf("blank.html") == -1 && hash.length > 0 && last_hash != hash)
      		   window.location.hash = hash; // set the current hash from iframe to browser url 
}var frag_ajax_hist_id = -1;var fragments = hash.split("/");var hist_id_name_len = fw_ajax_hist_id_fragment_name.length;for(var i = 0; i < fragments.length; i++){var frag = fragments[i];if(frag.substr(0,hist_id_name_len) == fw_ajax_hist_id_fragment_name){frag_ajax_hist_id = frag.substr(hist_id_name_len+1, frag.length);}}if(frag_ajax_hist_id != -1){if(_m_histIds.length > 0 && frag_ajax_hist_id != parseInt(_m_last_hist_id)){for(var i = 0; i < _m_histIds.length; i++){if(parseInt(_m_histIds[i]) == frag_ajax_hist_id){_m_last_hist_id = frag_ajax_hist_id;var func = unescape(_m_histReqs[i]);eval(func);}}}}}}
//--------------------------------------------------------------------            

//--------------------------------------------------------------------

// will be removed latest at version 1.9
fw_AjaxEnabled = false;fw_AjaxMaxConObj = 1;fw_Ajax = new Array();fw_AjaxError = new Array();fw_AjaxJS_Parsed = new Array();fw_AjaxTraceWin = null;
//--------------------------------------------------------------------
function fw_ajax_trace(msg){try{if(fw_AjaxTrace == true && msg.length > 0){cDate = new Date();var y = cDate.getFullYear().toString();var m = padL((cDate.getMonth()+1).toString(),"0",2);var d = padL(cDate.getDate().toString(),"0",2);var h = padL(cDate.getHours().toString(),"0",2);var i = padL(cDate.getMinutes().toString(),"0",2);var s = padL(cDate.getSeconds().toString(),"0",2);var ms = padL(cDate.getMilliseconds().toString(),"0",4);var cDate = y+"-"+m+"-"+d+" "+h+":"+i+":"+s+":"+ms;if(fw_AjaxTraceWin == null || ((typeof fw_AjaxTraceWin) == 'object' && fw_AjaxTraceWin.closed == true)){fw_AjaxTraceWin = window.open("", "crVCLAjaxTraceWin", "width=640,height=400,left=10,top=10,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,toolbar=no");fw_AjaxTraceWin.document.write("<head><title>crVCL Ajax Trace Window</title></head><b>crVCL Ajax Trace Window</b>");}if(msg.indexOf("init") > -1){fw_AjaxTraceWin.document.write("<br><br>");}fw_AjaxTraceWin.document.write(cDate+" - "+ msg +"<br>");fw_AjaxTraceWin.document.body.scrollTop = fw_AjaxTraceWin.document.body.scrollHeight;}}catch(e){}}
//--------------------------------------------------------------------
function fw_ajax_setConnections(max_connections){try{fw_AjaxMaxConObj = max_connections;
      if(fw_AjaxMaxConObj > fw_Ajax.length){ // add
var connections = fw_AjaxMaxConObj-fw_Ajax.length;for(var i = 0; i < connections; i++){fw_Ajax.push(null);fw_AjaxError.push(null);fw_AjaxJS_Parsed.push(false);}
       }else if(fw_AjaxMaxConObj < fw_Ajax.length){ // remove
var connections = fw_Ajax.length-fw_AjaxMaxConObj;for(var i = 0; i < connections; i++){fw_Ajax.pop();fw_AjaxError.pop();fw_AjaxJS_Parsed.pop();}}}catch(e){}
    // for debug

    //window.location.hash = ( "ajax_connections_open:"+fw_Ajax.length.toString() );
}
//--------------------------------------------------------------------

// private
fw_ajax_supported = false;function fw_ajax_init(id){if((typeof id) == "undefined"){fw_throw("id undefined, init ajax object failed");}fw_ajax_setConnections(fw_AjaxMaxConObj);try{for(var i = 0; i < fw_Ajax.length; i++){
          if((typeof id) == "object" || i == id){ // (typeof fw_Ajax[id]) == "object" => to check id is null
if(fw_Ajax[i] != null){fw_Ajax[i].abort(); fw_Ajax[i] = null;}try{
                 if(window.XMLHttpRequest){ // IE7, Mozilla, Opera and Safari
fw_Ajax[i] = new XMLHttpRequest();fw_ajax_trace("id:"+i+", init XMLHttpRequest");
                 }else if(window.ActiveXObject){ //  < IE7

                     for(var i2 = 6; i2; i2--){ // try load msxml dll version
try{
                             if(i2 == 1){ // load old version
fw_Ajax[i] = new ActiveXObject("Microsoft.XMLHTTP");fw_ajax_trace("id:"+i+", init Microsoft.XMLHTTP");}else if(i2 == 2){fw_Ajax[i] = new ActiveXObject("Msxml2.XMLHTTP");fw_ajax_trace("id:"+i+", init Msxml2.XMLHTTP");}else{fw_Ajax[i] = new ActiveXObject("Msxml2.XMLHTTP." + i2 + ".0");fw_ajax_trace("id:"+i+", init Msxml2.XMLHTTP." + i2 + ".0");}}catch(excNotLoadable){fw_Ajax[i] = null;}if(fw_Ajax[i] != null){break;}}}}catch(excNotLoadable){fw_Ajax[i] = null;}if(!fw_Ajax[i]){fw_AjaxError[i] = "ajax not init";}else{fw_AjaxError[i] = "";}
          } //if

       } // for
}catch(e){}try{if(fw_Ajax.length > 0 && fw_Ajax[0] != null){fw_ajax_supported = true;}}catch(e){}return;}
//--------------------------------------------------------------------
function fw_requestAjax(id, source, data, callback, type, wait, async){if(!data){data = '';}if(!callback){callback = "";}if(isNaN(type)){type = 1;}if(isNaN(wait)){wait = 0;}if(isNaN(async)){async = false;}if(source.length == 0){fw_throw("no ajax request page is set");return false;}var protocol = window.location.protocol;if(protocol == "https:"){source = source.replace(/http\:/, "https:");}else if(protocol == "http:"){source = source.replace(/https\:/, "http:");}
         //alert(typeof callback);

   // wait for init. of ajax  
if(wait != -1 && ((id >= fw_Ajax.length && fw_isPageLoaded() == false) || wait > 0 || !function_exists(callback))){if((fw_isPageLoaded() == false || !function_exists(callback)) && wait == 0){wait=1500;}window.setTimeout("eval(\"fw_requestAjax('"+id.toString()+"', '"+source+"', '"+data+"', '"+callback+"', "+type.toString()+", -1, "+async+")\")", wait);return false;}if(!fw_AjaxEnabled){fw_throw("AJAX is disabled from application side (call: "+source+")");return false;}if(id < 0 || id >= fw_Ajax.length){fw_throw("id "+id.toString()+" out of index, ajax request failed");return false;}
    // previous request not finished, abort it before sending a new request
if(fw_Ajax[id] != null && fw_Ajax[id].readyState > 0 && fw_Ajax[id].readyState < 4){fw_Ajax[id].abort();fw_Ajax[id] = null;}if(fw_Ajax[id] == null){fw_ajax_init(id);if(fw_Ajax[id] == null || fw_AjaxError[id].length > 0){return false};}if(type == 1 || type == 2){var now = new Date();if(data.length > 0){data = utf8_fix('&'+data);}data = 'request_timestamp='+now.getTime()+data;}try{switch(type){
			case 0: // HEAD
fw_Ajax[id].open("HEAD", source, async);data = null;fw_ajax_trace("id:"+id+", open HEAD "+source);break;
			case 2: // POST
data = utf8_fix(data);fw_Ajax[id].open("POST", source, async);fw_Ajax[id].setRequestHeader('Expires', 'Mon, 26 Jul 1970, 00:00:00 GMT');fw_Ajax[id].setRequestHeader('Cache-Control', 'no-store, no-cache, max-age=0, must-revalidate, post-check=0, pre-check=0');fw_Ajax[id].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');if(fw_Ajax[id].overrideMimeType)fw_Ajax[id].overrideMimeType('text/html; charset=UTF-8;');fw_Ajax[id].setRequestHeader('Content-Encoding', 'gzip, deflate');fw_Ajax[id].setRequestHeader('Content-Length', data.length);fw_ajax_trace("id:"+id+", open POST "+source);break;
			case 3: // XML
data = "xml=" + data;
			default: // GET
var file = source;if(data.length > 0){file += "?"+data;}fw_Ajax[id].open("GET", file, async);fw_Ajax[id].setRequestHeader('Expires', 'Mon, 26 Jul 1970, 00:00:00 GMT');fw_Ajax[id].setRequestHeader('Cache-Control', 'no-store, no-cache, max-age=0, must-revalidate, post-check=0, pre-check=0');fw_Ajax[id].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');if(fw_Ajax[id].overrideMimeType)fw_Ajax[id].overrideMimeType('text/html; charset=UTF-8;');fw_Ajax[id].setRequestHeader('Content-Encoding', 'gzip, deflate');data = null;fw_ajax_trace("id:"+id+", open GET "+file);}}catch(e){if(!fw_Ajax[id]){fw_AjaxError[id] = "error open ajax request";}return false;}fw_AjaxJS_Parsed[id] = false;if(async && callback.length > 0){try{
	     fw_Ajax[id].onreadystatechange = eval(callback); // only function name, parameters not allowed
}catch(e){fw_throw(e.message+" or ajax callback ("+callback+") not registered");}}
    // send request to server
try{fw_Ajax[id].send(data);fw_ajax_trace("id:"+id+", send "+source);}catch(e){if(!fw_Ajax[id]){fw_AjaxError[id] = "error send ajax request";return false;}}fw_AjaxError[id] = "";
	// set global key events back, because IE remain the last key state after ajax request
fw_keyCode = 0;fw_keyChr = "";fw_keyAlt = false;fw_keyCtrl = false;fw_keyShift = false;if(!async && callback.length > 0){try{
	     eval(callback+"();"); // only function name, parameters not allowed
}catch(e){fw_throw(e.message+" or ajax callback ("+callback+") not registered");}}return true;}
//--------------------------------------------------------------------
function fw_getAjaxError(id){return fw_AjaxError[id];}
//--------------------------------------------------------------------

// private
function fw_AjaxParseJS(responseText){var code = "";responseText = replaceAll(responseText, /\<SCRIPT/, "<script");responseText = replaceAll(responseText, /\<\/SCRIPT/, "</script");while(responseText.length > 0){var p = responseText.indexOf("\<script");if(p > -1){responseText = responseText.substring(p, responseText.length);p = responseText.indexOf("\>");if(p > -1){responseText = responseText.substring(p+1, responseText.length);p = responseText.indexOf("\<\/script\>");if(p > -1){code += responseText.substr(0, p);responseText = responseText.substring(p+9, responseText.length);}else{break;}}else{break;}}else{break;}}if(code.length == 0){return false;}var ret = null;var p = -1;while(true){p = code.indexOf("\<\!\-\-");if(p == -1){break;}var tmp = code.substring(0, p);code = code.substring(p+4);p = code.indexOf("\/\/\-\-\>");if(p > -1){code = code.substring(p+5);}code = tmp + code;}
   try{ // remove fw_AjaxParseJS comment to execute the script
var c1 = "\\/\\*fw_AjaxParseJS ";var c2 = " fw_AjaxParseJS\\*\\/";code = replaceAll(code, new RegExp(c1), "");code = replaceAll(code, new RegExp(c2), "");ret = eval(code);}catch(e){fw_throw("AjaxParseJS Error ("+e+", "+e.message+"):\n\n"+code.substr(0,300)+"\n\n.....");}return ret;}
//--------------------------------------------------------------------
function fw_get_AjaxRespone(id){return fw_Ajax[id].responseText;}
//--------------------------------------------------------------------
fw_AjaxHistId = new Array();fw_AjaxHistReq = new Array();fw_AjaxHistIdLast = "";fw_isSetAjaxHistoryHandleFrm2 = false;fw_blockHistoryHandleIE = false;function fw_AjaxHistoryHandle(){try{var hash = "";if(isIE() == false){hash = window.location.hash;}else{if(document.getElementById('AjaxHistoryHandleFrame2').src && !fw_isSetAjaxHistoryHandleFrm2){hash = document.getElementById('AjaxHistoryHandleFrame2').src;fw_isSetAjaxHistoryHandleFrm2 = true;}else{hash = String(document.getElementById('AjaxHistoryHandleFrame').contentWindow.document.location);}var pos = hash.indexOf("?");hash = hash.substr(pos+1, hash.length);pos = hash.indexOf("=");hash = hash.substr(pos+1, hash.length);hash = '#fw_ajax_hist_back'+hash;}if(hash.substr(0,18) == '#fw_ajax_hist_back'){var id = parseInt(hash.substr(18,hash.length));if(fw_AjaxHistId.length > 0 && id != parseInt(fw_AjaxHistIdLast) && !fw_blockHistoryHandleIE){for(var i = 0; i < fw_AjaxHistId.length; i++){if(parseInt(fw_AjaxHistId[i]) == id){fw_AjaxHistIdLast = id;var func = unescape(fw_AjaxHistReq[i]);eval(func);}}}}}catch(e){}}
//--------------------------------------------------------------------

// remove until here

//--------------------------------------------------------------------

//--------------------------------------------------------------------
function fw_mvc_event(name){var mvc_method = getObj('mvc_method');if(mvc_method == null){fw_throw("html 'form' tag is missing");return;}mvc_method.value = name;}
//--------------------------------------------------------------------
fw_utf8 = true;fw_ajax_hist_id_fragment_name = 'fw_ajax_hist_id';window.onload=fw_doc_init;window.onresize=fw_doc_resize;fw_last_window_width = getWindowWidth();fw_last_window_height = getWindowHeight();fw_last_doc_width = getDocWidth();fw_last_doc_height = getDocHeight();