var slideShowPic=0;var nextSlideShowPic=0;var continueSlideShow=1;var pics=new Array();jQuery(function(){if($("#profileId").html()==null){i()}function i(){$.post("dogs-data.php",{cmd:"start_slide_show"},function(m){$("#pictures").crossSlide({fade:1},m)},"json")}function d(n){var m=/^[a-zA-Z ]$/;return n.match(m)}function l(m){if(m.which==32||(65<=m.which&&m.which<=65+25)||(97<=m.which&&m.which<=97+25)){return true}else{return false}}function j(m){if(/[^a-z]/i.test(m.value)){m.value=m.value.replace(/[^a-z] /gi,"")}m.value+="";m.focus()}$("#name").livequery("keyup",function(o){var m=$(this).val();var p="";for(var n=0;n<m.length;n++){if(d(m[n])){p+=m[n]}}$(this).val(p);if(p==""){p="Dog"}$(".dogName").html(p+"'s")});$("#profileSaveButton").livequery("click",function(){if($("#profileId").html()==""){if($("#name").val().length<2){alert("Sorry, your dog's name is too short.");return}else{if(!confirm("Are you sure your dog's name, breed, and gender are correct? These values cannot be modified.")){return}}}$("#profile").load("dogs-data.php",{cmd:"save_profile",id:$("#profileId").html(),name:$("#name").val(),gender:$("[name=gender]:checked").val(),breed:$("#breed").val(),full_name:$("#full_name").val(),birthday:$("#birthday").val(),deceased:$("#deceased:checked").val(),food:$("#food").val(),snacks:$("#snacks").val(),toys:$("#toys").val(),activities:$("#activities").val(),shows:$("#shows").val(),out:"js"}).hide().fadeIn()});$("#profileEditButton").livequery("click",function(){$("#profile").fadeOut(1500,function(){$("#profile").load("dogs-data.php",{cmd:"edit_profile",id:$("#profileId").html(),out:"js"},function(){$("#profile").fadeIn(1500)})})});$(".deleteComment").livequery("click",function(){var m=$(this).attr("commentId");$("#comments").load("dogs-data.php",{cmd:"delete_comment",profile_id:$("#profileId").html(),comment_id:m})});$("#submitCommentButton").livequery("click",function(){if($("#newComment").val()==""){alert("Sorry, your comment is too short.");return}$("#comments").load("dogs-data.php",{cmd:"save_comment",profile_id:$("#profileId").html(),comment:$("#newComment").val()})});$("#profileAddButton").livequery("click",function(){$("#profile").load("dogs-data.php",{cmd:"edit_profile",id:0,out:"js"}).hide().fadeIn()});$("#profileDeleteButton").livequery("click",function(){if(confirm("Are you sure you want to delete the profile for "+$("#name").html()+"?")){$.post("dogs-data.php",{cmd:"delete_profile",id:$("#profileId").html()},function(){window.location="http://www.dogforum.com/dogs/"})}});$("#cancelProfileEditButton").livequery("click",function(){if($("#profileId").html()>1){window.location="http://www.dogforum.com/dogs/"+$("#url").html()+"_"+$("#profileId").html()}else{window.location="http://www.dogforum.com/dogs/"}});$("#profileId").livequery(function(){if($(this).html()>0){h()}});$(".fullImage").livequery("click",function(){$("#fullImageDiv").fadeOut(1500)});$(".thumbnail").livequery("click",e);function e(){var n=$(this).attr("src");var m=n.substr(0,n.lastIndexOf("-"))+"-800.jpg";$("#fullImageDiv").html('Click the image below to close it.<br><img class="fullImage" src="'+m+'">').hide().fadeIn(1500)}$(".thumbnail").livequery(function(){$(this).draggable({revert:true,containment:"#thumbnails"})});$(".thumbnail").livequery("mouseover",function(){continueSlideShow=0;var n=$(this).attr("src");var m=n.substr(0,n.lastIndexOf("-"))+"-300.jpg";$("#previewPic").css("backgroundImage","url("+$("#previewPic").attr("src")+")");$("#previewPic").html('<img src="'+m+'" width="300">');$("#previewPic img").hide().fadeIn("slow")});function a(){continueSlideShow=0}function g(){if(!continueSlideShow){console.log("Slideshow is disabled!");return}if(slideShowPic==pics.length){slideShowPic=0}nextslideShowPic=slideShowPic+1;if(nextslideShowPic==pics.length){nextslideShowPic=0}$("#previewPic").css("backgroundImage","url("+pics[nextSlideShowPic]+")");$("#previewPic img").fadeOut(3000,function(){$("#previewPic img").attr("src",pics[slideShowPic]);$("#previewPic img").fadeIn(3000,function(){g()})});slideShowPic++}function h(){console.log("Starting slide show");continueSlideShow=1;pics.length=0;$(".thumbnail").each(function(){var n=$(this).attr("src");var m=n.substr(0,n.lastIndexOf("-"))+"-300.jpg";pics.push(m)});if(pics.length==0){return}$("#previewPic").html('<img src="'+pics[1]+'">');slideShowPic=1;g()}$("#garbage").livequery(function(){$(this).droppable({accept:".thumbnail",drop:function(n,o){a();var p=$(o.draggable);$(p).unbind("click",e);var m=$(p).attr("id");$(p).remove();console.log("starting");$("#pictures").load("dogs-data.php",{cmd:"delete_picture",pic_id:m,profile_id:$("#profileId").html()},function(){console.log("finished");h()}).hide().fadeIn("slow")}})});$("#setDefaultPicture").livequery(function(){$(this).droppable({accept:".thumbnail",drop:function(n,o){var p=$(o.draggable);$(p).unbind("click",e);$(p).bind("click",e);var m=$(p).attr("id");$.post("dogs-data.php",{cmd:"set_default_picture",pic_id:m,profile_id:$("#profileId").html()},function(){alert($("#name").html()+"'s default picture has been updated.")})}})});$("#birthday").livequery(function(){var m=new Date();$("#birthday").datepicker({defaultDate:m,changeMonth:true,changeYear:true})});$("#imageUploadButton").livequery(function(){new AjaxUpload("imageUploadButton",{action:"dogs-data.php",name:"image_file",data:{securitytoken:SECURITYTOKEN,cmd:"upload_picture",profile_id:$("#profileId").html(),breed_url:$("#breedUrl").val()},onSubmit:function(m,n){if(!(n&&/^(jpg|JPG|JPEG|jpeg)$/.test(n))){alert("Error: You must upload a .jpg image.");return false}$("#ajaxLoaderGraphic").html('<img src="images/misc/loading.gif">').hide().fadeIn("slow")},onComplete:function(n,m){$("#ajaxLoaderGraphic").fadeOut("slow",function(){$(this).empty()});$("#pictures").load("dogs-data.php",{cmd:"print_pictures",profile_id:$("#profileId").html()},function(){h()}).hide().fadeIn("slow");var o=confirm("Would you like to share your dog's new photo with your friends on Facebook?");if(o){$("#my_fb_share").click()}}})});var f="";var c="";var k="";var b="";$("#tennisBall").livequery(function(){var m=$(this);soundManager.url="/soundmanager/";soundManager.onload=function(){b=soundManager.createSound({id:"aSound0",url:"/soundmanager/ball_settle.mp3",onload:function(){$(m).draggable().effect("bounce","slow")},onfinish:function(){}});b.play();f=soundManager.createSound({id:"aSound1",url:"/soundmanager/dog_up.mp3"});c=soundManager.createSound({id:"aSound2",url:"/soundmanager/dog_down.mp3"});k=soundManager.createSound({id:"aSound3",url:"/soundmanager/drop.mp3"})}});$("#tennisBall").livequery("click",function(){if($(".tennisBallDog").length<1&&$("#tennisBall").attr("own")!="true"){$("#tennisBallDiv").append('<img id="tennisBallDogsLoadingImage" src="images/misc/loading.gif">');$("#tennisBallDogsLoadingImage").hide().fadeIn("slow");$("#tennisBallDogsDiv").load("dogs-tennis-ball.php",{cmd:"get_user_dogs"},function(){$("#tennisBallDogsLoadingImage").fadeOut(function(){$(this).remove()})})}});$(".tennisBallDog").livequery(function(){var m=$(this);$(m).droppable({accept:"#tennisBall",drop:function(n,o){$.post("dogs-tennis-ball.php",{cmd:"update_ball",ball_id:$("#tennisBall").attr("ball_id"),dog_id:$("#profileId").html(),assign_id:$(m).attr("dog_id")},function(p){if(p==-1){alert("Sorry, somebody else already claimed this ball for their dog since you loaded the page. "+$(m).attr("dog_name")+" did not receive the ball.");$("#tennisBallDiv").fadeOut()}else{k.play();alert($(m).attr("dog_name")+" has the tennis ball now!");$("#tennisBallDiv").fadeOut()}})},over:function(n,o){f.play();$(this).animate({width:"250px"},500)},out:function(n,o){c.play();$(this).animate({width:"160px"},500)}})})});
