function fnGetArrayFromForm(i_form) {    	var l_arr = new Array();	for (var i = 0; i < i_form.getElementsByTagName('input').length; i++) {		l_el = { 			name:    i_form.getElementsByTagName('input')[i].name,			value:   i_form.getElementsByTagName('input')[i].value		};		l_arr.push(l_el);	};	for (var i = 0; i < i_form.getElementsByTagName('select').length; i++) {		l_el = { 			name:    i_form.getElementsByTagName('select')[i].name,			value:   i_form.getElementsByTagName('select')[i].value		};		l_arr.push(l_el);	};	for (var i = 0; i < i_form.getElementsByTagName('textarea').length; i++) {		l_el = { 			name:    i_form.getElementsByTagName('textarea')[i].name,			value:   i_form.getElementsByTagName('textarea')[i].value		};		l_arr.push(l_el);	};	return l_arr;}function get_class(obj) {    // Returns the name of the class of an object    //     // +   original by: Ates Goral (http://magnetiq.com)    // +   improved by: David James     if (obj instanceof Object && !(obj instanceof Array) &&        !(obj instanceof Function) && obj.constructor) {        var arr = obj.constructor.toString().match(/function\s*(\w+)/);         if (arr && arr.length == 2) {            return arr[1];        }    }     return false;} function serialize( mixed_val ) {    // Generates a storable representation of a value	//     // +   original by: Ates Goral (http://magnetiq.com)    // +   adapted for IE: Ilia Kantor (http://javascript.ru)     switch (typeof(mixed_val)){        case "number":            if (isNaN(mixed_val) || !isFinite(mixed_val)){                return false;            } else{                return (Math.floor(mixed_val) == mixed_val ? "i" : "d") + ":" + mixed_val + ";";            }        case "string":            return "s:" + mixed_val.length + ":\"" + mixed_val + "\";";        case "boolean":            return "b:" + (mixed_val ? "1" : "0") + ";";        case "object":            if (mixed_val == null) {                return "N;";            } else if (mixed_val instanceof Array) {                var idxobj = { idx: -1 };        var map = []        for(var i=0; i<mixed_val.length;i++) {            idxobj.idx++;                        var ser = serialize(mixed_val[i]);             if (ser) {                            map.push(serialize(idxobj.idx) + ser)            }        }                                                        return "a:" + mixed_val.length + ":{" + map.join("") + "}"             }            else {                var class_name = get_class(mixed_val);                 if (class_name == undefined){                    return false;                }                 var props = new Array();                for (var prop in mixed_val) {                    var ser = serialize(mixed_val[prop]);                     if (ser) {                        props.push(serialize(prop) + ser);                    }                }                return "O:" + class_name.length + ":\"" + class_name + "\":" + props.length + ":{" + props.join("") + "}";            }        case "undefined":            return "N;";    }     return false;}function unserialize ( inp ) {    // Creates a PHP value from a stored representation    //     // +   original by: Arpad Ray (mailto:arpad@php.net)     error = 0;    if (inp == "" || inp.length < 2) {        errormsg = "input is too short";        return;    }    var val, kret, vret, cval;    var type = inp.charAt(0);    var cont = inp.substring(2);    var size = 0, divpos = 0, endcont = 0, rest = "", next = "";     switch (type) {    case "N": // null        if (inp.charAt(1) != ";") {            errormsg = "missing ; for null";        }        // leave val undefined        rest = cont;        break;    case "b": // boolean        if (!/[01];/.test(cont.substring(0,2))) {            errormsg = "value not 0 or 1, or missing ; for boolean";        }        val = (cont.charAt(0) == "1");        rest = cont.substring(1);        break;    case "s": // string        val = "";        divpos = cont.indexOf(":");        if (divpos == -1) {            errormsg = "missing : for string";            break;        }        size = parseInt(cont.substring(0, divpos));        if (size == 0) {            if (cont.length - divpos < 4) {                errormsg = "string is too short";                break;            }            rest = cont.substring(divpos + 4);            break;        }        if ((cont.length - divpos - size) < 4) {            errormsg = "string is too short";            break;        }        if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") {            errormsg = "string is too long, or missing \";";        }        val = cont.substring(divpos + 2, divpos + 2 + size);        rest = cont.substring(divpos + 4 + size);        break;    case "i": // integer    case "d": // float        var dotfound = 0;        for (var i = 0; i < cont.length; i++) {            cval = cont.charAt(i);            if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) {                endcont = i;                break;            }        }        if (!endcont || cont.charAt(endcont) != ";") {            errormsg = "missing or invalid value, or missing ; for int/float";        }        val = cont.substring(0, endcont);        val = (type == "i" ? parseInt(val) : parseFloat(val));        rest = cont.substring(endcont + 1);        break;    case "a": // array        if (cont.length < 4) {            errormsg = "array is too short";            return;        }        divpos = cont.indexOf(":", 1);        if (divpos == -1) {            errormsg = "missing : for array";            return;        }        size = parseInt(cont.substring(1, divpos - 1));        cont = cont.substring(divpos + 2);        val = new Array();        if (cont.length < 1) {            errormsg = "array is too short";            return;        }        for (var i = 0; i + 1 < size * 2; i += 2) {            kret = unserialize(cont, 1);            if (error || kret[0] == undefined || kret[1] == "") {                errormsg = "missing or invalid key, or missing value for array";                return;            }            vret = unserialize(kret[1], 1);            if (error) {                errormsg = "invalid value for array";                return;            }            val[kret[0]] = vret[0];            cont = vret[1];        }        if (cont.charAt(0) != "}") {            errormsg = "missing ending }, or too many values for array";            return;        }        rest = cont.substring(1);        break;    case "O": // object        divpos = cont.indexOf(":");        if (divpos == -1) {            errormsg = "missing : for object";            return;        }        size = parseInt(cont.substring(0, divpos));        var objname = cont.substring(divpos + 2, divpos + 2 + size);        if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") {            errormsg = "object name is too long, or missing \":";            return;        }        var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1);        if (error) {            errormsg = "invalid object properties";            return;        }        rest = objprops[1];        var objout = "function " + objname + "(){";        for (key in objprops[0]) {            objout += "" + key + "=objprops[0]['" + key + "'];";        }        objout += "}val=new " + objname + "();";        eval(objout);        break;    default:        errormsg = "invalid input type";    }    return (arguments.length == 1 ? val : [val, rest]);}
