$(document).ready(function(){$("select#pages").change(function(){var last_added;$.postJSON("/slideshow/index/",{id:"stats",f_name:"clast_added"},function(data){last_added=data.layouts});var opt_text=$("select#pages option:selected").text();var opt_id=$("select#pages option:selected").attr("id");var name_id=$("select#pages").attr("name");var fetch=function(opt_text,opt_id){$("#data").removeClass().addClass("data");$.postJSON("/slideshow/index/",{id:name_id,f_name:opt_id+"_"+opt_text},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="";var sel="";for(i=1;i<=data.c_pnum;i++){opt_text==i?sel='selected="selected"':sel="";pages+="<option "+sel+' id="'+opt_id+'">'+i+"</option>"}$("#step1 dl .st_bottom select").html(pages);$.each(data.layouts,function(entryIndex,entry){var msg=(jQuery.inArray(entry.c,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(opt_text,opt_id)},3000))});$("#sv_cpanel span").toggle(function(){$(this).parent().siblings(".steps").children(".nd").removeClass("hidden");$(this).parent().siblings(".steps").css("left", "-100%");$(this).addClass("second");$("#step2 #step2_id_templ").focus()},function(){$(this).parent().siblings(".steps").animate({left:"0%"},500,function(){$(this).children(".nd").addClass("hidden")});$(this).removeClass("second")});$("#step2").find("input:button").click(function(){$("#login_wrapper").removeClass("hide").find(".login_cont:not(:hidden):first").find("input:text:first").focus()});$("#sv_njl_order #step2").validate({errorElement:"li",errorClass:"invalid",errorPlacement:function(error_msg,el){$(el).parent().parent().find(".sc_msg").html(error_msg.text())},highlight:function(el,errorClass){$(el).parent().parent().find("ul").removeClass().addClass(errorClass);$(el).parent().addClass(errorClass)},unhighlight:function(el,errorClass){$(el).parent().parent().find("ul").removeClass(errorClass);$(el).parent().removeClass(errorClass)},submitHandler:function(){var fForm=new Array(7);fForm[0]="step2";fForm[1]="/steps/step2";fForm[2]="post";fForm[3]="step2 #st_resp";fForm[4]="dl";fForm[5]="div";fForm[6]="json";var fRow=new Array(3);fRow[0]=1;fRow[1]="#layout ul";fRow[2]="valid";var fAnim=new Array(2);fAnim[0]="step2Success";fAnim[1]=500;$("#"+fForm[0]+" "+fRow[1]).children(".sc_msg").empty();setupAjaxForm(fForm,fRow,fAnim);return false},rules:{"step2[pages]":{required:true,maxlength:2,digits:true,number:true,min:1,max:50}},messages:{"step2[pages]":{required:"Required field",maxlength:"Maximum length: 2",digits:"Only digits allowed",number:"Only numbers allowed",min:"Minimum value: 1",max:"Maximum value: 50"}}})});
