/*
  (C) 2012 O'Mahony's Booksellers Ltd
*/
function resizeImage(a,b){var c=$(a).width();if(c>b){var d=0,e=$(a).height();d=b/c,$(a).css("width",b),$(a).css("height",e*d)}}function setupModal(){var a=$(document).height(),b=$(window).width();$("#mask").length===0&&$("body").append('<div id="mask"></div>'),$("#mask").css({width:b,height:a,opacity:.75})}function centerW(a){var b=$(window).height(),c=$(window).width(),d=document.body.scrollLeft||document.documentElement.scrollLeft||self.pageXOffset,e=document.body.scrollTop||document.documentElement.scrollTop||self.pageYOffset;d===undefined&&(d=0),e===undefined&&(e=0);var f=e+(b-$("#"+a+" > div").height())/2,g=d+(c-$("#"+a+" > div").width())/2;$("#"+a).css({top:f,left:g,"z-index":"9999",position:"absolute"}),$("#mask").fadeTo("fast",.75),$("#"+a+" > div").show()}function clearDefault(a){a.defaultValue===a.value&&(a.value="")}function setDefault(a){a.value===""&&(a.value=a.defaultValue)}function showHide(a,b){var c=document.getElementById(a);c.style.display==="block"?c.style.display="none":c.style.display="block"}function checkSearch(a){return quick_find.searchTerm.value===""?(alert("Please enter something to search for in the Search box."),quick_find.searchTerm.focus(),!1):!0}function showBox(a){popupTimerHandle!==null&&(clearTimeout(popupTimerHandle),popupTimerHandle=null);var b=document.getElementById(a);b.style.display="block"}function hideBox(a){popupTimerHandle=setTimeout("reallyHideBox('"+a+"');",250)}function reallyHideBox(a){var b=document.getElementById(a);b.style.display="none"}$(window).load(function(){$(".boxcontent img").each(function(){resizeImage(this,166)}),$(".prodlistFind .prodImage img").each(function(){resizeImage(this,80)}),$(".prodlistGrid .prodImage img.medImg").each(function(){resizeImage(this,148)}),$(".prodlistNum  .prodImage img.medImg").each(function(){resizeImage(this,120)}),$(".prodlistDef  .prodImage img.medImg").each(function(){resizeImage(this,120)}),$(".cartImg img").each(function(){resizeImage(this,100)})}),$(document).ready(function(){$(".cntForSale .butA2C").click(function(a){var b=this;$(b).attr("disabled","true");var c=$(this).closest(".cntForSale"),d=c.find("input[name=products_id]").val();if(d==0)return!0;a.preventDefault();var e=c.find("select").val(),f=c.find(".prodImage img"),g='<span class="covOl">Thank you for adding this to your Cart!</span>';if(e===0||e===undefined)e=1;$(this).attr("class","butA2Cadding"),f.fadeTo("slow",.2),$.get("om_ajax.php",{fn:"cart_add",pid:d,qty:e},function(a){$(a).find("res").each(function(){var a=$(this).find("box_intu").text(),d=$(this).find("box_cart").text();typeof d!="undefined"&&$("#box_cart").html(d),typeof a!="undefined"&&$("#box_intuition").html(a),c.find(".prodImage img").wrap('<div style="position:relative"/>').closest("div").append(g),f.delay(3e3).fadeTo("slow",1,function(){$(b).removeAttr("disabled"),c.find(".prodImage .covOl").remove(),c.find(".prodImage img").unwrap('<div style="position:relative"/>'),$(b).attr("class","butA2C")})})})}),$(".cntForSale .butA2WL").click(function(a){a.preventDefault();var b=this;$(b).attr("disabled","true");var c=$(this).closest(".cntForSale"),d=$(this).find("input[name=wl]").val(),e=c.find("input[name=products_id]").val(),f=c.find("select").val(),g=c.find(".prodImage img"),h=$(this).text(),i='<span class="covOl">Thank you for adding this to '+h+"!</span>";if(f===0||f===undefined)f=1;var j=$(b).html();$(b).html("Adding..."),g.fadeTo("slow",.2);if(e==0){var k=c.find("input[name=products_model]").val(),l=c.find("input[name=cart_quantity]").val(),m=c.find("input[name=products_image]").val(),n=c.find("input[name=products_price]").val(),o=c.find("input[name=rrp_price]").val(),p=c.find("input[name=products_date_available]").val(),q=c.find("input[name=products_format]").val(),r=c.find("input[name=products_weight]").val(),s=c.find("input[name=products_name]").val(),t=c.find("input[name=originator]").val(),u=c.find("input[name=products_description]").val(),v=c.find("input[name=hash]").val();$.get("om_ajax.php",{fn:"wish_add_nc",w:d,pm:k,cq:l,pi:m,pp:n,rp:o,pda:p,pf:q,pw:r,pn:s,o:t,pd:u,h:v},function(a){$(a).find("res").each(function(){var a=$(this).find("box_intu").text(),d=$(this).find("box_cart").text();typeof d!="undefined"&&$("#box_cart").html(d),typeof a!="undefined"&&$("#box_intuition").html(a),c.find(".prodImage img").wrap('<div style="position:relative"/>').closest("div").append(i),g.delay(3e3).fadeTo("slow",1,function(){$(b).removeAttr("disabled"),c.find(".prodImage .covOl").remove(),c.find(".prodImage img").unwrap('<div style="position:relative"/>'),$(b).html(j)})})})}else $.get("om_ajax.php",{fn:"wish_add",w:d,pid:e,qty:f},function(a){$(a).find("res").each(function(){var a=$(this).find("box_intu").text(),d=$(this).find("box_cart").text();typeof d!="undefined"&&$("#box_cart").html(d),typeof a!="undefined"&&$("#box_intuition").html(a),c.find(".prodImage img").wrap('<div style="position:relative"/>').closest("div").append(i),g.delay(3e3).fadeTo("slow",1,function(){$(b).removeAttr("disabled"),c.find(".prodImage .covOl").remove(),c.find(".prodImage img").unwrap('<div style="position:relative"/>'),$(b).html(j)})})})}),$(".createWishList").live("click",function(a){a.preventDefault();var b="cwl";$("#"+b).length>0?($("#"+b+" .stsmsg").html("").show(),$("#"+b+" .but_submit").removeAttr("disabled"),$("#"+b+" .but_cancel").removeAttr("disabled"),centerW(b),$("#wl_name").focus()):$.get("om_ajax.php",{fn:"get_modal",id:b},function(a){setupModal(),$("body").append('<div id="'+b+'" style="position:absolute;display:hidden"></div>'),$("#"+b).html(a),centerW(b),$("#wl_name").focus(),$(".overlayClose, .but_cancel").click(function(a){a.preventDefault(),$("#mask").hide(),$("#"+b+" > div").fadeOut("fast")}),$("#createWishListForm").submit(function(a){a.preventDefault();if($("#createWishListForm").valid()){$("#"+b+" .but_submit").attr("disabled","disabled"),$("#"+b+" .but_cancel").attr("disabled","disabled"),$("#"+b+" .stsmsg").html("").show();var c=$("input[name=wl_visi]:checked").val(),d=$("textarea[name=wl_desc]").val(),e=$("input[name=wl_name]").val(),f,g,h;$.get("om_ajax.php",{fn:"wish_create",wl_name:e,wl_desc:d,wl_visi:c},function(a){$(a).find("res").each(function(){f=$(this).find("box_cart").text(),g=$(this).find("sts").text(),h=$(this).find("msg").text()}),g=="0"?$("#"+b+" .stsmsg").html(h).delay(2e3).queue(function(){window.location.href=window.location.href}):($("#"+b+" .but_submit").removeAttr("disabled"),$("#"+b+" .but_cancel").removeAttr("disabled"),$("#"+b+" .stsmsg").html(h).delay(5e3).fadeOut(1e3))})}return!1})})});var a;$(".popWishlist").hover(function(){a=$(this).find("a").first().text(),$(this).addClass("hover"),$(this).find(".popList").css("display","block")},function(){$(this).removeClass("hover"),$(this).find(".popList").css("display","none")}),$(".cntForSale").hover(function(){$(this).find(".popWishlist").css("visibility","visible")},function(){$(this).find(".popWishlist").css("visibility","hidden")})});var popupTimerHandle=null
