function tBox(id) { if($(id).getStyle('display') == 'none') { Effect.toggle(id, 'appear'); } return; } function dataSubmit() { var form = $('tiny-form'); var forms = form.getElements(); var box = $('return-box'); var e = new Array(); for(i=0; i < forms.length; i++) { if(forms[i].value == '' &&forms[i].name !="pass") { e.push(forms[i].name); } } if(e.length == 0) { var param = form.serialize(true); new Ajax.Request("./submit", { method: "post", parameters: param, onSuccess: function(ret) { var rD = ret.responseXML; var resx = rD.getElementsByTagName("return"); //alert("Alert"+resx[0].getAttribute("status")+"FOR"+resx[0].firstChild.nodeValue); if(resx[0].getAttribute("status") == 1) { box.className = "success"; box.update('Your URL is short! Try accessing it with your key.'); $('info-box').update(resx[0].firstChild.nodeValue); tBox('info-box'); } else { box.className = "failure"; box.update(resx[0].firstChild.nodeValue); } }, onFailure: function() { box.className = "failure"; box.update('An error has occured. If the problem presists please report this error.'); } }); } else{ box.className = "failure"; box.innerHTML = 'All fields are required. Please fill the missing information.'; } tBox('return-box'); return false; }