$(function(){$("#images").click(function(){if($(this).parent().find("input[name=images]").val()=="YES"){$("#gallery-select").hide().find("select").val("null");$("#gallery-select-update").text($("#gallery-select select option:first").text());}else{$("#gallery-select").show();}});$.getJSON("http://demo.firerift.com/api/blog/blog_categories?user_id="+$.session.user.id,function(data){$(data.items).each(function(){$("#blog-select select").append("<option value='"+this.id+"'>"+this.name+"</option>");});});$.getJSON("http://demo.firerift.com/api/gallery/galleries?user_id="+$.session.user.id,function(data){$(data.items).each(function(){$("#gallery-select select").append("<option value='"+this.id+"'>"+this.title+"</option>");});});$("#blog-select").change(function(){$("#blog-select-update").text($("select[name=blog_category_id] option:selected").text());});$("#gallery-select").change(function(){$("#gallery-select-update").text($("select[name=gallery_id] option:selected").text());});$("form[name=posttext]").submit(function(){var errStr="";if($(this).find("input[name=feed_url]").val()==""){errStr="Please enter a valid RSS or ATOM Feed URL.";}else if($(this).find("select[name=blog_category_id]").val()=="null"){errStr="Please choose a Blog Category to import this Feed to.";}else if($(this).find("select[name=gallery_id]").val()=="null"&&$(this).find("input[name=images]").val()=="YES"){errStr="Please choose a Gallery to Copy the Images over to.";}
if(errStr!=""){$("#alert-holder").html('<div id="alert-warning">'+errStr+'</div>').fadeIn("normal").fadeTo(4500,1).fadeOut("normal");}else{$.ajax({type:"POST",url:"http://demo.firerift.com/api/blog/import",data:$(this).serialize(),error:function(){$("#alert-holder").html(tips[1]).fadeIn("normal").fadeTo(4500,1).fadeOut("normal");},success:function(){$("#alert-holder").html('<div id="alert-success">Your Feed has been successfully Imported.</div>').fadeIn("normal").fadeTo(4500,1).fadeOut("normal");}});}
return false;});});
