/*globals $,ibuyproperties,window*/ ibuyproperties.sellForm = (function(){ "use strict"; function init(){ if (ibuyproperties.isDebugMode) { console.log("Form-Init"); } //open page1 if no page is given if (window.location.hash.match(new RegExp("^#Sell[/]*$"))) {window.location+="/page1/";} ibuyproperties.router.addRoute("^#Sell/page1",function(){ ibuyproperties.navShow('pnl_sell','sell_userInfo'); }); ibuyproperties.router.addRoute("^#Sell/page2",function(){ ibuyproperties.navShow('pnl_sell','sell_propAddress'); }); ibuyproperties.router.addRoute("^#Sell/page3",function(){ ibuyproperties.navShow('pnl_sell','sell_propInfo'); }); ibuyproperties.router.addRoute("^#Sell/thanks",function(){ ibuyproperties.navShow('pnl_sell','sell_thanks'); }); ibuyproperties.router.addRoute("^#Sell/sendError",function(){ ibuyproperties.navShow('pnl_sell','sell_sendError'); }); } function sendForm(){ if (ibuyproperties.isDebugMode) { console.log("Sending Form"); } var formInfo=ibuyproperties.helpers.toJSO($("#pnl_Sell")); if (ibuyproperties.isDebugMode) { console.log("Form-data",formInfo); } $.ajax({ type:"POST", url:"/postForward.php", dataType:"json", contentType:"application/json", data: JSON.stringify(formInfo), success:function(msg,jqXHR,status) { console.log("send-success method",msg,jqXHR,status); window.location="#Sell/thanks"; }, error:function(jqXHR,status,error){ console.log("send-error method",jqXHR,status,error); window.location="#Sell/sendError"; } }); } return { init:init, sendForm:sendForm }; }());