var recenterDialog = function() {}; UtilitiesNS = {}; (function () { UtilitiesNS.getStackTrace = (function () { var mode; try {(0)()} catch (e) { mode = e.stack ? 'Firefox' : window.opera ? 'Opera' : 'Other'; } switch (mode) { case 'Firefox' : return function () { try {(0)()} catch (e) { return e.stack.replace(/^.*?\n/,''). replace(/(?:\n@:0)?\s+$/m,''). replace(/^\(/gm,'{anonymous}('). split("\n"); } }; case 'Opera' : return function () { try {(0)()} catch (e) { var lines = e.message.split("\n"), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*?in\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i, i,j,len; for (i=4,j=0,len=lines.length; i\n"; nextCaller = nextCaller.caller; } stackTraceMessage += "
\n\n"; // display message return stackTraceMessage; //document.getElementById("output").innerHTML = stackTraceMessage + document.getElementById("output").innerHTML; } function getSignature(theFunction) { var signature = getFunctionName(theFunction); signature += "("; for(var x=0; x 30) nextArgument = nextArgument.substring(0, 30) + "..."; // apend the next argument to the signature signature += "'" + nextArgument + "'"; // comma seperator if(x < theFunction.arguments.length - 1) signature += ", "; } signature += ")"; return signature; } function getFunctionName(theFunction) { // mozilla makes it easy. I love mozilla. if(theFunction.name) { return theFunction.name; } // try to parse the function name from the defintion var definition = theFunction.toString(); var name = definition.substring(definition.indexOf('function') + 8,definition.indexOf('(')); if(name) return name; // sometimes there won't be a function name // like for dynamic functions return "anonymous"; } /** * openModalDialog * Opens a 'modal dialog' over the page. * "url" is the url where to take the object to show, via ajax. * "options" are arguments passed via ajax to the url if called. * "obj", if defined, is directly the DOM object to show (get it with $(obj), duplicate, put it into the form) * "form", needed if we're using "obj", if the form from which we copy the onsubmit (a little bit of a hack... we simply copy the onsubmit attr) * "onComplete" is called if the whole opening has succeded */ function openModalDialog(url, options, obj, form, onComplete) { // close all tooltip ToolTipCloseAll(); // close previous modal dialogs var oldModal = $('ModalDialogContainer'); if($defined(oldModal)) oldModal.remove(); // check options if(!$defined(options)) options = {}; // enrich options with section name options.sectionName = $('Section').value; var border = 10; // 10 px of border both top and bottom try { // get the 'modal' var d = $E('body'); // get window size var left = window.getScrollLeft(); var top = window.getScrollTop(); var width = window.getScrollWidth(); var viewWidth = window.getWidth(); var height = window.getScrollHeight(); // add the background //var background = new Element('div', { // 'id': 'ModalDialogBackground', // 'styles': { // opacity: 0, // display: 'block', // position: 'fixed', // left: '0px', // top: '0px', // width: '100%', // height: '100%', // 'z-index': 10, // 'background-color': 'black' // }, // id: 'ModalDialogBackground' //}); //d.adopt(background); // add the form to display via ajax var newDiv = new Element('div', { 'id': 'ModalDialogContainer', 'styles': { position: 'absolute', float: 'left', opacity: 1, top: '' + (border + Window.getScrollTop()) + 'px', 'background-color': 'white', 'z-index': -10 // to avoid being seen till ready } }); d.adopt(newDiv); // function which finalize the aspect once the (potential) ajax is completed var realCompletedFunction = function() { // reposition the element at the center of the page var form = newDiv.getFirst(); var formWidth = form.getSize().scrollSize.x; newDiv.setStyle('left', Math.max(0, (viewWidth-formWidth)/2)); // recompute height of hiding screen now height = window.getScrollHeight(); //background.setStyle('height', height+border); // really show it newDiv.setStyle('z-index', 20); // make it draggable new Drag.Base(newDiv, { handle: $E('#ModalDialogContainer .box-header') }); // make it resizable //var mdc = $('ModalDialogContainer'); //mdc.makeResizable({handle: mdc.getElement('.resize_corner')}); // ok, we've done everything if($defined(onComplete)) onComplete(); }; recenterDialog = realCompletedFunction; // wrapper to wait for the update part of the AJAX to be ready var delayToWait = 50; var completedFunction = function() { //alert(stackTrace(arguments.callee)); if($defined(newDiv.getFirst())) { realCompletedFunction(); } else { completedFunction.delay(delayToWait); delayToWait *= 2; } } if(!$defined(obj)) { new AjaxReload(url, { method: 'post', data: Object.toQueryString(options), update: newDiv, evalScripts: true, onSuccess: completedFunction, onFailure: function(transport) { text = transport.responseText; newDiv.setHTML('
' + text + '

'); newDiv.setStyle('left', viewWidth/4); newDiv.setStyle('width', viewWidth/2); height = window.getScrollHeight(); //background.setStyle('height', height+border); } }).request(); } else { var text; var obj_onsubmit; var newobj; if($type(obj) == "string" && !$defined($(obj))) { text = obj; obj_onsubmit = function() {}; newobj = new Element('div'); newobj.innerHTML = text; } else { // possibly resolve it obj = $(obj); text = obj.innerHTML; obj_onsubmit = obj.onsubmit; // dup newobj = obj.clone(); } // evaluate scripts var scripts = []; var regexp = /]*>([\s\S]*?)<\/script>/gi; while ((script = regexp.exec(text))) scripts.push(script[1]); scripts = scripts.join('\n'); if(window.execScript) window.execScript(scripts); else window.setTimeout(scripts, 0); newobj.onsubmit = obj_onsubmit; // move it inside the form newobj.injectInside(newDiv); // copy onsubmit var theForm = $E('#ModalDialogContainer form'); if($defined(theForm)) theForm.onsubmit = form.onsubmit; // center! realCompletedFunction(); } // ok, show it d.setStyle('display', 'block'); //new Fx.Style(background, 'opacity', {duration: 300}).start(0.85); } catch(e) { alert(e); } finally { return false; } } function closeModalDialog() { tinyMCE.editors.each(function(editor, k) { requestDebug("barraca, barraca destroy: ", editor); var e = tinyMCE.remove(editor); if($defined(e)) e.destroy(); }); tinyMCE.editors = []; mdc = $('ModalDialogContainer'); if($defined(mdc)) mdc.remove(); mdb = $('ModalDialogBackground'); if($defined(mdb)) mdb.remove(); recenterDialog = function() {}; } /* Autocompletion functions: CAP, VAT, ... */ var AutocompleteNS = { // bind these HTML elements so that city+country computes to zipcode and country+zipcode computes to city. bindForZipcode: function(city, country, zipcode) { city = $(city); country = $(country); zipcode = $(zipcode); if($defined(city.bindedForZipcode)) { requestDebug('skipping bindForZipcode'); return; } update_zipcode = function() { new AjaxReload('http://www.cuboware.com/reQUEST/model/Zipcodes/get_zipcode_by_city', { data: Object.toQueryString({city: city.value, country: country.value}), onComplete: function(text, xml) { zipcode.value = text; } }).request(); }; update_city = function() { new AjaxReload('http://www.cuboware.com/reQUEST/model/Zipcodes/get_city_by_id', { data: Object.toQueryString({id: zipcode.value, country: country.value}), onComplete: function(text, xml) { city.value = text; } }).request(); }; city.addEvent('change', update_zipcode); country.addEvent('change', update_zipcode); /*zipcode.addEvent('change', update_city);*/ city.bindedForZipcode = true; }, // bind those elements together so the change of any parameter brings an update in the vat bindForVAT: function(country, zipcode, city, surname, firstname, birthdate, birthdate_displayed, sex_radios, vat) { if($defined(country.bindedForVAT)) { requestDebug('skipping bindForVAT'); return; } update = function() { new AjaxReload('http://www.cuboware.com/reQUEST/model/get_vat', { data: Object.toQueryString({ country: country.value, surname: surname.value, name: firstname.value, birthdate: birthdate.value, sex: sex_radios.filter(function(x) { return x.checked; })[0].value, birthplace: city.value }), onSuccess: function(text, xml) { vat.value = text; } }).request(); }; country.addEvent('change', update); zipcode.addEvent('change', update); city.addEvent('change', update); surname.addEvent('change', update); firstname.addEvent('change', update); birthdate_displayed.forEach(function(x) { x.addEvent('change', update); }); sex_radios.forEach(function(x) { x.addEvent('change', update); }); country.bindedForVAT = true; }, // bind those elements together so the change of any parameter brings an update in the vat bindForVATAmount: function(price, vat_amount, percentage, fix_amount, fix_thresold, vat_percentage, typ, number, total_price) { price = $(price); if($defined(price.bindedForVATAmount)) { requestDebug('skipping bindForVATAmount'); return; } update = function() { var new_price = price.value.toFloat(); if(vat_percentage) var new_percentage = vat_percentage.value.toFloat(); else var new_percentage = percentage; var new_vat_amount = new_price * new_percentage/100; if(fix_amount != null && new_price > fix_thresold) new_vat_amount = new_vat_amount + fix_amount; vat_amount.value = Math.round(Math.round(new_vat_amount*1000)/10)/100; if($defined(total_price)) total_price.value = new_price + new_vat_amount; }; update_by_vat_amount = function() { var new_price = price.value.toFloat(); if(new_price) { var new_vat_amount = $(vat_amount).value.toFloat(); if(fix_amount != null && new_price > fix_thresold) new_vat_amount = new_vat_amount - fix_amount; var new_percentage = new_vat_amount*100/new_price; new_percentage = Math.round(Math.round(new_percentage*1000)/10)/100; vat_percentage.value = new_percentage; if($defined(total_price)) total_price.value = new_price + new_vat_amount; } }; update_number = function() { new AjaxReload('http://www.cuboware.com/reQUEST/model/Invoices/get_max_number', { data: Object.toQueryString({'typ': typ.value}), onComplete: function(text, xml) { number.value = text? text.toInt()+1 : 1; } }).request(); }; update_by_total_price = function() { var new_total_price = total_price.value.toFloat(); if(vat_percentage) var new_percentage = vat_percentage.value.toFloat(); else var new_percentage = percentage; var new_price = new_total_price * 100.0 / (100.0+new_percentage); var new_vat_amount = new_price * new_percentage/100; if(fix_amount != null && new_price > fix_thresold) { new_vat_amount = new_vat_amount + fix_amount; new_price = new_price - fix_amount; } vat_amount.value = Math.round(Math.round(new_vat_amount*1000)/10)/100; price.value = new_total_price - Math.round(Math.round(new_vat_amount*1000)/10)/100; } price.addEvent('change', update); if(vat_percentage) { vat_percentage.addEvent('change', update); vat_amount.addEvent('change', update_by_vat_amount); } if($defined(typ)) { typ.addEvent('change', update_number); } if($defined(total_price)) { total_price.addEvent('change', update_by_total_price); } price.bindedForVATAmount = true; }, bindForCheckout: function(percentage, fix_amount, fix_thresold, price, booking_fee, extras, net_price, tax, total_price, earnest_money, to_be_paid, vat_percentage) { price = $(price); if($defined(price.bindedForCheckout)) { requestDebug('skipping bindForCheckout'); return; } update_total = function() { new_price = price.value.toFloat(); new_booking_fee = booking_fee.value.toFloat(); new_extras = extras.value.toFloat(); new_earnest_money = earnest_money.value.toFloat(); new_total_price = new_price+new_booking_fee+new_extras; new_to_be_paid = new_total_price - new_earnest_money; if(vat_percentage) new_percentage = $(vat_percentage).value.toFloat(); else new_percentage = percentage; // FIXME per ricevute dovrebbe usare new_total_price e non new_to_be_paid tbp = new_to_be_paid; new_vat_amount = tbp * (1 - 1/(1+new_percentage/100)); if(fix_amount != null && tbp > fix_thresold) new_vat_amount = new_vat_amount + fix_amount; new_net_price = tbp - new_vat_amount; //net_price.innerHTML = floatToDecimal(new_net_price,2); tax.value = floatToDecimal(new_vat_amount,2); total_price.innerHTML = floatToDecimal(new_total_price,2); to_be_paid.innerHTML = floatToDecimal(new_to_be_paid,2); }; update_tax = function() { new_price = price.value.toFloat(); new_booking_fee = booking_fee.value.toFloat(); new_extras = extras.value.toFloat(); new_total_price = new_price+new_booking_fee+new_extras; //new_net_price = new_total_price - tax.value.toFloat(); net_price.innerHTML = floatToDecimal(new_net_price,2); }; price.addEvent('change', update_total); booking_fee.addEvent('change', update_total); extras.addEvent('change', update_total); earnest_money.addEvent('change', update_total); tax.addEvent('change', update_tax); price.bindedForCheckout = true; }, // make a standard bind for zipcode, that is, between fields called 'field[_name]_city', 'field[_name]_country', // and 'field[_name]_zipcode' standardZipcodeBind: function(name) { city = ['field']; country = ['field']; zipcode = ['field']; if($defined(name)) { city.push(name); country.push(name); zipcode.push(name); } city.push('city'); country.push('country'); zipcode.push('zipcode'); city = city.join('_'); country = country.join('_'); zipcode = zipcode.join('_'); AutocompleteNS.bindForZipcode( $E('#ModalDialogContainer [name=' + city + ']'), $E('#ModalDialogContainer [name=' + country + ']'), $E('#ModalDialogContainer [name=' + zipcode + ']') ); }, // make a bind for rate, price, nights and guests bindForRate: function(rate, price, nights, guests, internet_fee, mode, room_id, checkin, earnest_money) { update_price_by_rate = function() { var r = rate.value.toFloat(); var g = guests.value.toInt(); var n = nights.value.toInt(); if(!n) n = 1; var f = internet_fee.value.toFloat(); price.value = floatToDecimal(f+r*g*n,2); if($defined(earnest_money) && earnest_money.value.toFloat() > price.value.toInt()) earnest_money.value = price.value; }; update_rate_by_price = function() { var p = price.value.toFloat(); var g = guests.value.toInt(); var n = nights.value.toInt(); if(!n) n = 1; var f = internet_fee.value.toFloat(); rate.value = floatToDecimal((p-f)/g/n,2); }; update_rate_and_price = function() { var r = rate.value.toFloat(); if($defined(mode) && mode.value == 'Recompute') r = r; // FIXME must do: price = container.model.room.get_price(id=room_id, start=checkin, nights=nights, guests=guests, rent_whole_room_only=rent_whole_room_only) rate.value = floatToDecimal(r,2); update_price_by_rate(); }; price.addEvent('change', update_rate_by_price); rate.addEvent('change', update_price_by_rate); nights.addEvent('change', update_rate_and_price); guests.addEvent('change', update_rate_and_price); if($defined(room_id)) room_id.addEvent('change', update_rate_and_price); checkin.addEvent('change', update_rate_and_price); }, bindForPaid: function(form, price, paid, tobepaid) { update_tobepaid = function() { var myprice = price.textContent.toFloat(); var mypaid = paid.value.toFloat(); var tot = floatToDecimal(myprice - mypaid ,2); if (tot < 0) tot = 0; if (isNaN(tot)) tot = myprice; tobepaid.textContent = tot; }; form.addEvent('reset', update_tobepaid); paid.addEvent('blur', update_tobepaid); }, // make a bind for rate, price, nights and guests, paid, tobepaid bindForPayment: function(form, rate, price, nights, guests, internet_fee, mode, room_id, checkin, earnest_money, paid, tobepaid) { update_tobepaid = function() { var myprice = price.value.toFloat(); var mypaid = paid.value.toFloat(); var tot = floatToDecimal(myprice - mypaid ,2); if (tot < 0) tot = 0; if (isNaN(tot)) tot = myprice; tobepaid.textContent = tot; }; form.addEvent('reset', update_tobepaid); paid.addEvent('blur', update_tobepaid); price.addEvent('change', update_tobepaid); update_paid_and_tobepaid_by_price = function(myprice) { var mypaid = paid.value.toFloat(); var tot = floatToDecimal(myprice - mypaid ,2); if (tot < 0) tot = 0; if (isNaN(tot)) tot = myprice; tobepaid.textContent = tot; }; update_price_by_rate = function() { var r = rate.value.toFloat(); var g = guests.value.toInt(); var n = nights.value.toInt(); if(!n) n = 1; var f = internet_fee.value.toFloat(); price.value = floatToDecimal(f+r*g*n,2); if($defined(earnest_money) && earnest_money.value.toFloat() > price.value.toInt()) earnest_money.value = price.value; update_paid_and_tobepaid_by_price(price.value.toFloat()); }; update_rate_by_price = function() { var p = price.value.toFloat(); var g = guests.value.toInt(); var n = nights.value.toInt(); if(!n) n = 1; var f = internet_fee.value.toFloat(); rate.value = floatToDecimal((p-f)/g/n,2); }; update_rate_and_price = function() { var r = rate.value.toFloat(); if($defined(mode) && mode.value == 'Recompute') r = r; // FIXME must do: price = container.model.room.get_price(id=room_id, start=checkin, nights=nights, guests=guests, rent_whole_room_only=rent_whole_room_only) rate.value = floatToDecimal(r,2); update_price_by_rate(); update_paid_and_tobepaid_by_price(price.value.toFloat()); }; price.addEvent('change', update_rate_by_price); rate.addEvent('change', update_price_by_rate); nights.addEvent('change', update_rate_and_price); guests.addEvent('change', update_rate_and_price); if($defined(room_id)) room_id.addEvent('change', update_rate_and_price); checkin.addEvent('change', update_rate_and_price); }, bindForCitySearch: function(container, country_field, city_field, zipcode_field) { country_field = $(country_field); city_field = $(city_field); zipcode_field = $(zipcode_field); city_field.addEvent('change', function() { new AjaxReload("http://www.cuboware.com/reQUEST/contextmenu/get_city_list", { evalScripts: true, update: container, data: Object.toQueryString({'city': city_field.value}), onComplete: function(text) { var timer = (function() { var citylist = $('citylist'); if(!$defined(citylist)) return; $clear(timer); citylist.getElements('input[type=radio]').each(function(radio) { radio.addEvent('click', (function(event) { var fields = event.target.value.split('@@@@'); if($defined(city_field)) city_field.value = fields[1]; if($defined(zipcode_field)) zipcode_field.value = fields[2]; }).bindWithEvent(radio)); }); }).periodical(300); } }).request(); }); }, bindForUserSearch: function(fields, userChosenCallback) { requestDebug('bindForUserSearch(', fields, ')'); // get out HTML elements for(var key in fields) fields[key] = $E('#ModalDialogContainer [name=' + fields[key] + ']'); requestDebug('fields is', fields); // make the additional div which will contain the results var search_result_div = new Element('div', {id: 'add_reservation_search_list'}); var fieldset = null; for(var key in fields) { fieldset = fields[key]; break; } while(fieldset.getTag() != 'fieldset') fieldset = fieldset.getParent(); search_result_div.injectAfter(fieldset.getLast()); // function to run the search run_search = function(values) { requestDebug('values is', values); if($defined(fields.language)) fields.language.focus(); // empty == null in this case for(var key in values) if(values[key] == '') values[key] = null; // no arguments? no call. var ok = false; for(var key in values) { ok = true; break; } if(!ok) return; // run the search new AjaxReload("http://www.cuboware.com/reQUEST/contextmenu/get_user_list", { evalScripts: true, update: search_result_div, data: Object.toQueryString(values), onComplete: function() { (function() { // every radio can fill the form var first = true; $$('#add_reservation_search_list input[type=radio]').forEach(function(radio) { var f = function() { var data = this.getAttribute('class').split('@@@@'); var id = data[15]; data = { customer_id : data[15], email: data[1], mobile: data[2], surname: data[3], language: data[4], city: data[5], address: data[6], id_type: data[7], id_number: data[8], name: data[9], sex: data[10], nationality: data[11], birthplace_country: data[12], birthplace_city: data[13], birthdate: data[14], country: data[16]}; for(var key in data) if($defined(fields[key])) { requestDebug('settings fields[', key, '].value (=', fields[key], ') = ', data[key]); fields[key].value = data[key]; } if($defined(userChosenCallback)) userChosenCallback(id, data); } radio.addEvent('click', f); //if(first) { f.bind(radio)(); first = false; } // autoselect first entry if(first) { radio.checked = false; first = false; } // autodeselect first entry }); }).delay(200); } }).request(); } // add handler var make_func = function(key) { return function() { var arg = {}; arg[key] = fields[key].value; run_search(arg); } } var search_fields = {'email': null, 'surname': null, 'mobile': null}; for(var key in search_fields) if($defined(fields[key])) fields[key].addEvent('blur', make_func(key)); }, bindForSmsToOperators: function(form, operators, numsms) { if($defined(operators.bindedForSmsToOperators)) { requestDebug('skipping bindForSmsToOperators'); return; } update_numsms = function() { var n = 0; for(var i=0; icancel
"); var children = container.getChildren(); for(var i = 0; i < children.length; i++) { var d = children[i]; if(d.id == 'bodyslotsubstitute_data') { dataDiv = d; break; } } // put it in the DOM at the top container.injectTop($E('body')); } else dataDiv = $('bodyslotsubstitute_data'); // make the request and fill if(ajaxReloadParameters == null) ajaxReloadParameters = {}; ajaxReloadParameters.update = dataDiv; ajaxReloadParameters.evalScripts = true; if($defined(data)) ajaxReloadParameters.data = Object.toQueryString(data); console.method = 'post'; new AjaxReload(url, ajaxReloadParameters).request(); // btw, close all tooltips ToolTipCloseAll(); } } /* Autotranslate functions */ var AutotranslateNS = { doTranslation: function(text, language, translated_widget, signature) { if(signature) text += '\n(translated by Google)'; google.language.detect(text, function(result) { if (!result.error && result.language) { google.language.translate(text, result.language, language, function(result) { if (result.translation) translated_widget.value = result.translation.unescapeHTML(); }); } }); }, // a map between field names and a boolean: if the user has manually changed a field (rather than letting it be edited by google translate) _editedFields: {}, // whether we're currently applying translations _translating: false, bindForTranslation: function (autotranslate_name, multilingual_name_prefix, signature) { if(!$defined(google)) return; if(!$defined(signature)) signature = 1; var languages = ['it']; // reset the _editedFields languages.forEach(function(lang) { AutotranslateNS._editedFields['field_' + multilingual_name_prefix + '_' + lang] = false; }); // bind translation code for(var i = 0; i < languages.length; i++) { var w = $E('textarea[name=field_'+multilingual_name_prefix+'_'+languages[i]+']'); if($defined(w)) { w.addEvent('change', function(event) { if(AutotranslateNS._translating) return; AutotranslateNS._translating = true; var autotranslate = $('field_'+autotranslate_name).checked; // mark the field as edited (user entered some input) or not edited (user left the field blank) AutotranslateNS._editedFields[this.getAttribute('name')] = this.value > ''; // check whether to translate the field and do it if necessary if(autotranslate && this.value > '') { for(var j = 0; j < languages.length; j++) { var fieldname = 'field_' + multilingual_name_prefix + '_' + languages[j]; var ww = $E('textarea[name=' + fieldname + ']'); if(!$defined(ww)) requestDebug("bindForTranslation: node", fieldname, "not found"); // translate the field only if it is empty or not marked as edited by the user if(ww.value == '' || !AutotranslateNS._editedFields[fieldname]) { AutotranslateNS.doTranslation(this.value, languages[j], ww, signature); } } } AutotranslateNS._translating = false; }.bind(w)); } } } } /** * * AJAX IFRAME METHOD (AIM) * http://www.webtoolkit.info/ * **/ AIM = { // this variable is set to "true" by the forms's code, and back to "false" just before making an AIM request loadingCompleted : false, frame : function(c) { var n = 'f' + Math.floor(Math.random() * 99999); var d = window.document.createElement('div'); d.innerHTML = ''; while(true) { window.document.body.appendChild(d); var i = window.document.getElementById(n); if(!$defined(i)) continue; else break; } requestDebug('got the iframe', i); //this.i = i; var doc = this._documentFromIframe(i); var bod = $(doc.body); // cannot use mootools machinery because explorer // doesn't like inter-frame element injection, and // all "new Element" elements are created using main // frame, whereas we are working on an inner frame. bod.innerHTML = bod.innerHTML + "
"; if (c && typeof(c.onComplete) == 'function') { i.onComplete = c.onComplete; } if (c && typeof(c.onFailure) == 'function') { i.onFailure = c.onFailure; } return n; }, form : function(f, url, name) { f.setAttribute('target', name); f.setAttribute('action', url); }, submit : function(url, f, c) { requestDebug('resetting the loading completed flag'); AIM.loadingCompleted = false; dw = window; var n = AIM.frame(c); AIM.form(f, url, n); if (c && typeof(c.onStart) == 'function') { c.onStart(); } else { true; } /* var formClone = new Element('form', { method: f.method, enctype: f.enctype, action: f.action, target: f.target, 'class': 'cloned', styles: {display: 'none'} }); formClone.inject($E('body')); var cloner = function(inp) { inp.clone().injectInside(formClone); }; f.getElements('input').forEach(cloner); f.getElements('select').forEach(cloner); f.getElements('textarea').forEach(cloner); */ f.submit(); //formClone.submit(); var aimchecktimer = function() { i = $(n); if(!$defined(i)) { requestDebug("i not defined"); return; } else requestDebug("check for", n); var nodes = this._documentFromIframe(i).body.childNodes; //requestDebug('nodes.length =', nodes.length, '; loadingCompleted =', AIM.loadingCompleted); //if(nodes.length > 0) requestDebug('nodes[0] =', nodes[0], '; nodes[0].nodeType =', nodes[0].nodeType); if(nodes.length == 0 || nodes[0].tagName == 'PRE' || nodes[0].tagName == 'H2' || ($defined(nodes[0].getAttribute) && nodes[0].getAttribute('class') != 'aimcheckpresence' && AIM.loadingCompleted)) { // finished loading if(this.loaded(n)) { $clear(aimchecktimer); //formClone.remove(); i.remove(); } } }.periodical(300, this); }, _documentFromIframe: function(i) { if($defined(i.name)) return frames[i.name].document; else if ($defined(i.document)) { return i.document; } else if ($defined(i.contentDocument)) { return i.contentDocument; } else if ($defined(i.contentWindow)) { return i.contentWindow.document; } else { return window.frames[id].document; } }, loaded : function(id) { var i = document.getElementById(id); var d = this._documentFromIframe(i); // if(d.getElementById('error_extra')) { if(typeof(i.onFailure) == 'function') { i.onFailure(d.body.innerHTML); } } else // if (typeof(i.onComplete) == 'function') { i.onComplete(d.body.innerHTML); } return true; } } var requestDebug = function() { }; var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if(!isChrome && $defined(window.console) && $defined(console.debug)) requestDebug = console.debug; WizardNS = { // the group of the wizard we're currently editing current_group: null, // the step of the wizard we're currently editing current_step: null, // data of the current wizard: a list of steps, where each step is // an object with two keys, "group", the name of the group in this // step, and "fields", a map between field names and values steps: [], // given an element, find the form it's in _getFormFromElement: function(el) { el = $(el); while($defined(el.getTag) && el.getTag() != 'form') el = el.getParent(); if(!$defined(el.getTag)) return null; else return el; }, // eval the