jQuery(document).ready(function($){$('#LoginWithAjax_Form').submit(function(event){event.preventDefault();$('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo('#LoginWithAjax');var url=$('#LoginWithAjax_Form').attr('action');var postData=getPostData('#LoginWithAjax_Form *[name]');postData['login-with-ajax']='login';$.post(url,postData,function(data){lwaAjax(data,'LoginWithAjax_Status','#login-with-ajax');if(data.result===true){if(data.widget!=null){$.get(data.widget,function(widget_result){$('#LoginWithAjax').replaceWith(widget_result);$('#LoginWithAjax_Title').replaceWith($('#LoginWithAjax_Title_Substitute').text());});}else{if(data.redirect==null){window.location.reload();}else{window.location=data.redirect;}}}},"json");});$('#LoginWithAjax_Remember').submit(function(event){event.preventDefault();$('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo('#LoginWithAjax');var url=$('#LoginWithAjax_Remember').attr('action');var postData=getPostData('#LoginWithAjax_Remember *[name]');$.post(url,postData,function(data){lwaAjax(data,'LoginWithAjax_Status','#login-with-ajax');},"json");});$('#LoginWithAjax_Register form').submit(function(event){event.preventDefault();$('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo('#LoginWithAjax_Register');var url=$('#LoginWithAjax_Register form').attr('action');var postData=getPostData('#LoginWithAjax_Register form *[name]');$.post(url,postData,function(data){lwaAjax(data,'LoginWithAjax_Register_Status','#LoginWithAjax_Register');},"json");});$('#LoginWithAjax_Remember').hide();$('#LoginWithAjax_Links_Remember').click(function(event){event.preventDefault();$('#LoginWithAjax_Remember').show('slow');});$('#LoginWithAjax_Links_Remember_Cancel').click(function(event){event.preventDefault();$('#LoginWithAjax_Remember').hide('slow');});function lwaAjax(data,statusElement,prependTo){$('#LoginWithAjax_Loading').remove();if(data.result===true||data.result===false){if(data.result===true){if($('#'+statusElement).length>0){$('#'+statusElement).attr('class','confirm').html(data.message);}else{$('<span id="'+statusElement+'" class="confirm">'+data.message+'</span>').prependTo(prependTo);}}else{if($('#'+statusElement).length>0){$('#'+statusElement).attr('class','invalid').html(data.error);}else{$('<span id="'+statusElement+'" class="invalid">'+data.error+'</span>').prependTo(prependTo);}
$('#'+statusElement).click(function(event){event.preventDefault();$('#LoginWithAjax_Remember').show('slow');});}}else{if($('#'+statusElement).length>0){$('#'+statusElement).attr('class','invalid').html('An error has occured. Please try again.');}else{$('<span id="'+statusElement+'" class="invalid">An error has occured. Please try again.</span>').prependTo(prependTo);}}}
function getPostData(selector){var postData={};$.each($(selector),function(index,el){el=$(el);postData[el.attr('name')]=el.attr('value');});return postData}});