function $_GET(name){// FUNCTION TO ACT LIKE PHP'S $_GET SUPERGLOBAL var url=window.location.search.substring(1); var get=url.split("&"); for (i=0; i < get.length; i++) { var val=get[i].split("="); if(val[0]==name){ return val[1]; } } } function resizeCart(){// RESIZES HEIGHT OF CART $('#cartPreview').css({visibility:'hidden',display:'block'}); var cartHeight=$('#cartPreview .wrap').height(); $('#cartPreview').css({visibility:'visible',display:'none'}); $('#cartPreview').height(cartHeight); } function prepareZoom(e){// CALLBACK FUNCTION FOR MAGNIFIER var id=e.children()[0].id; var num=e.children().length; if(id=='f1'){ e.css('display','block').addClass('active'); } else{ setTimeout(function(){ e.css('display','none');},100); } if((id=='f'+num)){ $('#full').css({'height':'auto','overflow':'visible'}); } } function refreshCart(formData){// REFRESHES CART PREVIEW BOX, THEN DISPLAYS AND RE-ASSIGNS CLICK FUNCTIONALITY var isError=formData.split(/-/g).length-1; if(isError < 1){ $.ajax({ url: "http://www.theperfectgift.co.nz/snippets/xshop/cartPreview.php", cache: false, success: function(html){ $("#content-header .r").empty().append(html); setTimeout(function(){ resizeCart(); $('#cartPreview').slideDown(500,'easeOutBack').addClass('visible'); setTimeout(function(){ if($('#cartPreview').hasClass('visible')){ $('#cartPreview').slideUp(400,'easeInBack').removeClass('visible'); } },2000); },600); $('#cartPreviewButton').css('outline','none').attr({href:'javascript:void(0);'}).bind('click',function(){ if($('#cartPreview').hasClass('visible')){ $('#cartPreview').slideUp(400,'easeInBack').removeClass('visible'); } else{ $('#cartPreview').slideDown(500,'easeOutBack').addClass('visible'); } }); $('#cartPreview').bind('mouseleave',function(){ if($('#cartPreview').hasClass('visible')){ $('#cartPreview').slideUp(400,'easeInBack').removeClass('visible'); } }); } }); } } function updateSearchFields(){// UPDATES ADVANCED PRODUCT SEARCH FIELDS BASED ON CATEGORY SELECTED var cat=$('#searchOpts select#cat').val(); var brand=$('#searchOpts select#b').val(); $.ajax({ url: "http://www.theperfectgift.co.nz/snippets/xshop/shopData.php?ajax=1&cat="+cat+"&b="+brand, cache: false, success: function(html){ $('#searchOpts').empty().append(html); $('#searchOpts select#cat').change(function(){ updateSearchFields(); }); } }); } jQuery(function($){ // INIT SEARCH BOX EMPTY FUNCTIONALITY $('#searchBox form input:first-child').focus(function(){ if(this.value==this.defaultValue){ this.value=""; } }).blur(function(){ if(this.value==''){ this.value=this.defaultValue; } }); // ADD CART PREVIEW FUNCTIONALITY resizeCart(); $('#cartPreviewButton').css('outline','none').attr({href:'javascript:void(0);'}).bind('click',function(){ if($('#cartPreview').hasClass('visible')){ $('#cartPreview').slideUp(400,'easeInBack').removeClass('visible'); } else{ $('#cartPreview').slideDown(500,'easeOutBack').addClass('visible'); } }); $('#cartPreview').bind('mouseleave',function(){ if($('#cartPreview').hasClass('visible')){ $('#cartPreview').slideUp(400,'easeInBack').removeClass('visible'); } }); // CREATE PRODUCT PHOTO GALLERY if($('#t1').length){ $('#thumbs img').mousedown(function(){ var id=this.id.replace('t','#f'); var thumb=this.id.replace('t','#t'); if($('#registry').length){ if(!$(id).hasClass('active')){ $('#full .active').removeClass('active').fadeOut(300, function(){ $(id).fadeIn(200).addClass('active'); $('#thumbs .active').removeClass('active'); $(thumb).addClass('active'); }); } }else{ if($('#full .w').length){ if(!$(id).parent().hasClass('active')){ $('#full .active').removeClass('active').fadeOut(300, function(){ $(id).parent().fadeIn(200).addClass('active'); $('#thumbs .active').removeClass('active'); $(thumb).addClass('active'); }); } }else{ if(!$(id).hasClass('active')){ $('#full .active').removeClass('active').fadeOut(300, function(){ $(id).fadeIn(200).addClass('active'); $('#thumbs .active').removeClass('active'); $(thumb).addClass('active'); }); } } } }); } // ADD CURRENCY CONVERTER FUNCTIONALITY if($('#converter').length){ var btn=$('span#converter a'); $(btn).attr({'href':'javascript:void(0);','target':''}).click(function(){ // GET CURRENT PRODUCT PRICE IF APPLICABLE if($('#x_price').length){ var price=$('#x_price').text().replace('$',''); }else{ var price=1; } // DEFINE CONVERTER HTML var form='\