function setupAjaxForm(fForm,fRow,fAnim){var form_id="#"+fForm[0];var target_base="#"+fForm[3];var target_def=target_base+" "+fForm[4];var target_new=target_base+" "+fForm[5];var options={url:fForm[1],type:fForm[2],target:"#"+fForm[3],dataType:fForm[6],beforeSubmit:showRequest,success:showResponse};function disableInputs(){$(form_id+" input").not(":submit, :button, :hidden").attr("readonly","readonly").css({backgroundColor:"#ddd",color:"#999"});$(form_id+" input:submit").attr("disabled","disabled")}function enableInputs(){$(form_id+" input").not(":submit, button, :hidden").removeAttr("readonly").removeAttr("style");$(form_id+" input:submit").removeAttr("disabled")}function responseMsg(cls,msg,speed){$(target_def).hide();$(target_new).hide().removeClass().addClass(cls).html(msg).fadeIn(speed)}function showRequest(formData,jqForm,options){disableInputs();responseMsg("load","loading..",10);return true}function showResponse(responseText,statusText){if(responseText.resp==0){enableInputs()}else{if(fRow[0]==1){$(fRow[1]).removeClass().addClass(fRow[2]).fadeIn(10,showAnimation(fAnim[0],responseText,fAnim[1]))}else{showAnimation(fAnim[0],responseText,fAnim[1])}}responseMsg("resp_ajax_"+responseText.resp,responseText.msg,100)}function showAnimation(a1,p1,a2){if(a2!=0){var fn=eval(a1);setTimeout(function(){fn(p1)},a2)}}function loginSuccess(p1){$("#login_wrapper").hide(10,function(){$(this).siblings("#header").children(".hd_login").removeClass("out").addClass("in");$(this).siblings("#header").children(".hd_login").children("a").html("Hello "+p1.user);$("#step2").find("input:submit").removeClass().addClass("stm").removeAttr("disabled");$("#step2").find("input:button").removeClass().addClass("hide");$("#step2").find("input#step2_user").val(p1.user);$("#step2").find("input#step2_acc_ref").val(p1.acc_ref);$("#step2").find("input#step2_email").val(p1.email)})}function step2Success(){$(form_id+" "+fRow[1]).children(".sc_msg").html("Email sent");enableInputs()}function keywordSuccess(p1){enableInputs();$("select#pages").attr("name","keywords");$("#data #layout .top img").attr("src","images/null.gif");var arr_last_added;$.postJSON("/slideshow/index/",{id:"stats",f_name:"clast_added"},function(data){arr_last_added=data.layouts});var fetch=function(){$.postJSON("/slideshow/index/",{id:"keywords",f_name:p1.criteria+"_1"},function(data){$("#step1 dl .st_content:eq(0) span").html(data.c_name);$("#step1 dl .st_content:eq(1) span").html(data.c_lnum);$("#step1 dl .st_content:eq(2) span").html(data.c_pnum);$("#step1 dl .st_bottom span:eq(1)").html(data.c_pnum);var pages="";if(data.c_pnum==0){pages+='<option id="'+p1.criteria+'">0</option>'}else{$("#data").removeClass().addClass("data");for(i=1;i<=data.c_pnum;i++){pages+='<option id="'+p1.criteria+'">'+i+"</option>"}}$("#step1 dl .st_bottom select").html(pages);if(data.layouts.length==0){setTimeout(function(){$("#loader").hide()},2000)}else{$.each(data.layouts,function(entryIndex,entry){var msg=(jQuery.inArray(entry.c,arr_last_added)<0)?"":"new!";$("#data .square:eq("+entryIndex+")").removeClass("hide");$("#data .square:eq("+entryIndex+") .bottom .bl").html(msg);$("#data .square:eq("+entryIndex+") .code").html(entry.c);$("#data .square:eq("+entryIndex+") .top a").attr("rel","/popup/Index/?ext="+entry.t+"&num="+entry.c);$("#data .square:eq("+entryIndex+") .top a").attr("name",entry.c);$("#data .square:eq("+entryIndex+") .top a img").attr("src","images/thumbs/"+entry.c.toString().slice(0,-2)+"00/"+entry.c+"-m.jpg");if((entryIndex+1)==data.layouts.length){setTimeout(function(){$("#loader").hide()},2000);$("#data .square:gt("+entryIndex+")").addClass("hide")}})}})};$("#loader").show(10,setTimeout(function(){fetch()},3000))}function layoutSuccess(p1){enableInputs();$("select#pages").attr("name","layouts");var arr_last_added;$.postJSON("/slideshow/index/",{id:"stats",f_name:"clast_added"},function(data){arr_last_added=data.layouts});var fetch=function(){$.postJSON("/slideshow/index/",{id:"layouts",f_name:p1.layout},function(data){$("#step1 dl .st_content:eq(0) span").html(data.c_name);$("#step1 dl .st_content:eq(1) span").html(data.c_lnum);$("#step1 dl .st_content:eq(2) span").html(data.c_pnum);$("#step1 dl .st_bottom span:eq(1)").html(data.c_pnum);$("#step1 dl .st_bottom select").html("<option>"+data.c_pnum+"</option>");if(data.layouts.length==0){setTimeout(function(){$("#loader").hide()},2000)}else{$("#data").removeClass().addClass("big");$.each(data.layouts,function(entryIndex,entry){var msg=(jQuery.inArray(entry.c,arr_last_added)<0)?"":"new!";$("#data #layout").removeClass("hide");$("#data #layout .bottom .bl").html(msg);$("#data #layout .code").html(entry.c);$("#data #layout .top img").attr("src","http://images.templatemonster.com/screenshots/"+entry.c.toString().slice(0,-2)+"00/"+entry.c+entry.t);if((entryIndex+1)==data.layouts.length){setTimeout(function(){$("#loader").hide()},2000)}})}})};$("#loader").show(10,setTimeout(function(){fetch()},3000))}$(form_id).ajaxSubmit(options)};