$(document).ready(function() { /* HANDLE TOGGLE VALUES IN INPUT BOXES */ var x = 0; $(".toggle").each(function() { togglevals[x] = $(this).val(); $(this).attr({"togglenum":x}); x++; }); $(".toggle").click(function() { var togglenum = $(this).attr("togglenum"); if ($(this).val() == togglevals[togglenum]) $(this).val(""); }); $(".toggle").bind("blur",function() { var togglenum = $(this).attr("togglenum"); if ($(this).val() == '') $(this).val(togglevals[togglenum]); }); /* END TOGGLE BOX HANDLING */ /* HANDLE HOVER EFFECTS */ $(".fade").css({"opacity":0.5}); $(".fade").hover(function() { $(this).fadeTo("slow",0.9); },function() { $(this).fadeTo("fast",0.5); }); /* END HOVER EFFECTS */ /* HANDLE HOVER IMAGE CHANGES */ $(".flip").hover(function() { if ($(this).attr("class").indexOf("flip") < 0) return false; $(this).attr({"src":$(this).attr("src").replace(/images\/images\//g,"images/")}); $(this).attr({"src":$(this).attr("src").replace("images/","images/images/")}); },function() { if ($(this).attr("class").indexOf("flip") < 0) return false; $(this).attr({"src":$(this).attr("src").replace("images/images/","images/")}); }); /* END HOVER IMAGE CHANGES */ /* HANDLE ROTATING PHOTO ARRAY */ if ($(".photoRotator img").length > 1) g_pictimer = setTimeout("rotateMainPic()",7000); /* show shopping cart if needed */ if ($("#cartBox").length > 0) showCart(); /* SIGNUP BUTTON */ $("#signupButton").click(function() { var e = $("#signupBoxEmail"); if (echeck(e.val())) { var im = $(this); im.attr({"src":"images/iconLoadingSmall.gif"}).removeClass("flip"); $.ajax({ type: "POST", url: "ajax.php", data: "action=doContactSignup&e="+e.val(), success:function(resp) { e.val(''); im.attr({"src":"images/button_go.png"}).addClass("flip"); alert("All Done - You have been added to our newsletter mailing list!"); } }); } else alert("Please enter your Email Address"); }); /* END SIGNUP BUTTON */ /* SWAP PHOTO BUTTONS */ if ($("#nextPhotoLink").length > 0) { $("#nextPhotoLink").click(function() { showSwapPhoto(null,1); return false; }); $("#prevPhotoLink").click(function() { showSwapPhoto(null,0); return false; }); } /* COLOR BOX */ if ($(".colorbox").length > 0) $(".colorbox").colorbox({width:"650px", height:"400px", iframe:true}); }); function closeColor() { $.fn.colorbox.close(); } function refreshcolor() { location.reload(true); } /* AUTO ROTATING PHOTOS */ var g_curpic = 1; var g_pictimer = ''; function rotateMainPic() { if (g_pictimer != '') clearTimeout(g_pictimer); $("#pic"+g_curpic).fadeOut("slow",null); g_curpic++; if (g_curpic > g_maxpics) g_curpic = 1; $("#pic"+g_curpic).fadeIn("slow",function() { g_pictimer = setTimeout("rotateMainPic()",7000); }); } /* END AUTO ROTATING PHOTOS */ /* SWAP PHOTO */ function showSwapPhoto(id,direction) { if (id == null) { var ids = getNextAndPrevPhoto(); id = ids[direction]; if (id == undefined) return false; } $('.swapGallery img:visible').hide(); $('#photo-'+id).show(); //$("#galleryTop .right a").removeClass("selected"); $("#photoNav a").removeClass("selected"); //$("#galleryTop .right a#link-"+id).addClass("selected"); $("#photoNav a#link-"+id).addClass("selected"); getNextAndPrevPhoto(); return false; } function getNextAndPrevPhoto() { //var cur = $("#galleryTop .right a.numLink").index($(".selected")); var cur = $("#photoNav a.numLink").index($(".selected")); //var max = $("#galleryTop .right a.numLink").length; var max = $("#photoNav a.numLink").length; if (max == 1 || cur == -1) $("#nextPhotoLink, #prevPhotoLink").hide(); else { var next = cur+1; var prev = cur-1; if (next < max) { //var nextImgId = $("#galleryTop .right a.numLink:eq("+next+")").attr("id").replace("link-",""); var nextImgId = $("#photoNav a.numLink:eq("+next+")").attr("id").replace("link-",""); if (nextImgId*1 == 0) $("#nextPhotoLink").addClass("disabled"); else $("#nextPhotoLink").removeClass("disabled"); } else $("#nextPhotoLink").addClass("disabled"); if (prev >= 0) { //var prevImgId = $("#galleryTop .right a.numLink:eq("+prev+")").attr("id").replace("link-",""); var prevImgId = $("#photoNav a.numLink:eq("+prev+")").attr("id").replace("link-",""); if (prevImgId*1 == 0) $("#prevPhotoLink").addClass("disabled"); else $("#prevPhotoLink").removeClass("disabled"); } else $("#prevPhotoLink").addClass("disabled"); } return [prevImgId,nextImgId]; } /* END SWAP PHOTO */ /* CONTACT FORM */ function submitContactForm() { var s = $(".input input, .input textarea").serialize(); var invalid = false; $(".req").each(function() { if ($(this).val() == '') invalid = true; }); if (invalid === true) { alert("Please fill in all required fields. Thank you."); return false; } else { if ($("#cbox").attr("checked") == true) var addCbox = "&doNews=1"; else var addCbox = ""; $.ajax({ type: "POST", url: "ajax.php", data: "action=doSaveContact&"+s+addCbox, success: function(resp) { $(".input input, .input textarea").val(""); alert("Thank you! We have received your message and will get in touch with you shortly."); } }); } } /* END CONTACT FORM */