var AJAX_URL="/smoothy/resources/ajaxpost.php";var SLIDESHOW_TIMER=7;$(document).ready(function(){loadRatings();checkTextLinks();loadLocalScroll();loadRandomTip();if($("#slideshow").length>0){Slideshow.init()}$(".add-comments").click(function(){return showCommentForm()})});Slideshow={isPlaying:false,navExists:false,navText:[],noBorderElements:[],init:function(){$("#slideshow div img").each(function(A){if(this.alt.length>0){Slideshow.navText[A]=this.alt}});if(Slideshow.navText.length==0){return }$("#slideshow").after('<div id="slideshow-nav"><div class="bg"><div/></div><div class="items"/><div id="slideshow-nav-control"/></div>');$("#slideshow").cycle({fx:"fade",pager:"#slideshow-nav .items",timeout:SLIDESHOW_TIMER*1000,before:function(C,B,A){Slideshow.moveNavSlider(A.nextSlide)}});this.isPlaying=true;$("#slideshow-nav .items a").each(function(A){if(Slideshow.navText[A]==undefined){$(this).empty()}else{$(this).html(Slideshow.navText[A])}});$("#slideshow-nav .items a:last").css("background","none");if(!Slideshow.navExists){Slideshow.moveNavSlider(0);Slideshow.navExists=true}$("#slideshow-nav-control").click(function(){if(Slideshow.isPlaying){$("#slideshow").cycle("pause");$("#slideshow-nav-control").addClass("playButton");Slideshow.isPlaying=false}else{$("#slideshow").cycle("resume");$("#slideshow-nav-control").removeClass("playButton");Slideshow.isPlaying=true}})},moveNavSlider:function(A){var D=$("#slideshow-nav .items a").get(A);if(D!=undefined){D=$(D);var C=D.offset().left-$("#slideshow-nav").offset().left;var B=D.width()+20;$("#slideshow-nav .bg").animate({left:C,width:B},"normal","swing",function(){if(Slideshow.noBorderElements.length>0){$(Slideshow.noBorderElements).each(function(){this.removeClass("noBg")})}Slideshow.noBorderElements=[D.prev(),D];$(Slideshow.noBorderElements).each(function(){this.addClass("noBg")})})}}};function loadLocalScroll(){$("a[href*=#]").each(function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname&&this.hash.replace(/#/,"")){var B=$(this.hash),C=$("[name="+this.hash.slice(1)+"]");var A=B.length?B:C.length?C:false;if(A){var D=A.offset().top;$(this).click(function(){$("html, body").animate({scrollTop:D},400);return false})}}})}function loadRandomTip(){$(".random-tip").click(function(){$(this).hide();var A=$("#tip-content div");$("#tip-content").css("height",$("#tip-content").height());A.hide();A.before(getLoadingScreen("loading new tip..."));$.getJSON(AJAX_URL+"?action=random_tip&breakCache="+Math.random()*10000000000000000,function(B){removeLoadingScreen();A.html("<strong>"+B.pagetitle+"</strong><br/><br/>"+B.content);A.show();$("#tip-content").css("height","auto");$(".random-tip").show()});return false})}function checkTextLinks(){if($(".textlinks div").size()>0){$(".textlinks").show()}}function loadRatings(){var D=$("div#ratings");if(D.size()==0){return }var B=$("div#ratings ul");var A=$("div#ratings a");var C=$("div#ratings small");A.each(function(){$(this).click(function(){B.hide();C.html("Thanks for voting!");rating=$(this).text();url=window.location.href;$.post(url,{rating:rating,js:"1"},function(E){html=$(E).html();setTimeout(function(){D.html(html)},500)});return false})})}function imageZoom(A){window.open("http://s7ondemand1.scene7.com/s7ondemand/zoom/flashb_zoom.jsp?company=DoItYourself&sku="+A+"&zoomwidth=420&zoomheight=470&vc=skin=/is-viewers/flash/basicZoomSkin.swf","_blank","location=no, toolbar=no, status=no, menubar=no, resizable=no, width=425, height=470")}function noImage(A){A.src="/assets/images/noimage.gif"}function logout(){if(confirm("Are you sure you want to log out?")){return true}else{return false}}function showCommentForm(){if($("#user_comment").length>0){$("#btn_leave_comment").hide();$("#user_comment").val("");$("#comment-form").slideDown("fast");return false}}function hideCommentForm(){$("#comment-form").hide();$("#btn_leave_comment").show()}function saveComment(){var A=$("#user_comment").val();if(A==""){alert("You must type in a comment first.");$("#user_comment").focus();return false}$("#comment-form").before(getLoadingScreen("saving comment..."));$("#comment-form").hide();if(window.location.href.indexOf("show=comments")!=-1){showall=1}else{showall=0}$.post(AJAX_URL,{action:"save_comment",contentid:CONTENTID,comment:A,showall:showall},function(B){if(msg=checkError(B)){error(msg);showCommentForm();$("#user_comment").val(A)}else{$("#usercomments").replaceWith(B);hideCommentForm()}removeLoadingScreen()});return false}function editComment(A){var B=$("#comment_"+A+" p");var C=$.trim(B.html());C=C.replace(/<br>/gi,"\n");B.hide();B.after('<textarea id="textarea_comment_'+A+'">'+C+'</textarea><div id="btn_save"><button onclick="updateComment(\''+A+"');\">Save</button><button onclick=\"cancelEditComment('"+A+"');\">Cancel</button></div>");$("#textarea_comment_"+A).focus();return false}function cancelEditComment(A){var B=$("#comment_"+A+" p");$("#textarea_comment_"+A).remove();$("#btn_save").remove();B.show();return false}function updateComment(A){var B=$("#comment_"+A+" p");var C=$("#textarea_comment_"+A).val();var D=$("#usercomments");B.before(getLoadingScreen("saving comment..."));$.post(AJAX_URL,{action:"update_comment",comment_id:A,comment:C,contentid:CONTENTID},function(E){if(msg=checkError(E)){error(msg)}else{D.replaceWith(E)}removeLoadingScreen()});return false}function deleteComment(A){if(confirm("Are you sure to want to delete this comment?\nThis can't be undone.")){$.post(AJAX_URL,{action:"delete_comment",comment_id:A},function(B){msg=checkError(B);if(msg){error(msg)}else{$("#comment_"+A).remove();alert(B)}})}return false}function flagComment(A){if(!confirm("You are about to send warning of this comment to an Editor.\n\nContinue?")){return false}btn=$("#btn_flagcomment_"+A);btn.hide();btn.after(getLoadingScreen("sending request..."));$.post(AJAX_URL,{action:"flag_comment",comment_id:A,url:window.location},function(B){if(msg=checkError(B)){error(msg)}else{alert(B)}removeLoadingScreen();btn.show()});return false}function voteComment(B,A){$("#comment_"+B+" .comment-rating").html("Your vote has been saved, thanks!");$.post(AJAX_URL,{action:"vote_comment",comment_id:B,vote:A},function(C){if(msg=checkError(C)){error(msg)}});return false}function showAllComments(A){$("#usercomments").html(getLoadingScreen("loading..."));$.post(AJAX_URL,{action:"show_all_comments",contentid:CONTENTID},function(B){$("#usercomments").replaceWith(B)});return false}function getLoadingScreen(A){return'<div id="loading_screen"><img class="noborder" src="/assets/images/indicator.gif"/>'+A+"</div>"}function removeLoadingScreen(){$("#loading_screen").remove()}function error(A){if(A!=null){alert(A)}}function checkError(A){var B=A.indexOf("error::");if(B!=-1){return A.substr(B+7)}else{return false}};