/** * Esellution Store Global JavaScript * http://esellution.co.uk * modified 2011/Nov/11 */ // Country select box generation on basket page 08/03/2011 $(function(){ var country_selects = $('#country_selects'); if (country_selects.length > 0) { country_selects.find('select').live('change', function(){ if ( $(this).val() !== '' ) { $.post('store/express_shipping', $(this).closest('form').serializeArray(), function(data){ country_selects.html(data); }); return false; } }); } }); // Bookmarking Capability function addToFavourites() { if (window.sidebar) { //Firefox window.sidebar.addPanel(document.title,self.location,''); } else if (window.chrome) { //Chrome alert('To bookmark this page, please click OK and then press CTRL+D on your keyboard, or click the star icon in the address bar.'); } else if (window.external) { //IE window.external.AddFavorite(self.location,document.title); } else if (window.opera) { //Opera - see jQuery below } else { //Safari etc alert('To bookmark this page, please click OK and then press CTRL+D on your keyboard.'); } } $(function(){ // Opera Bookmarking Capability var faveLink = $('#social li.link-bookmark a'); if (window.opera) { faveLink.attr({'rel':'sidebar','href':self.location,'title':document.title}); } // CSS manipulation - declare that JS is enabled.. (deprecate this) $('body').removeClass('no-js').addClass('js'); // Poplight amendment: Fade in Background 16:38 08/03/2011 $('body').append('
'); //Add the fade layer to bottom of the body tag. $('.popup_block').each(function(){ $('#fade').after( $(this) ); }); // Gallery + PrettyPhoto $(document).ready(function(){ $("a[rel^='prettyPhoto']").prettyPhoto(); }); // Gallery + PrettyPhoto $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'facebook',slideshow:2000, autoplay_slideshow: false}); $(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000}); $("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({ custom_markup: '
', changepicturecallback: function(){ initialize(); } }); //login modal - forgot password functionality var loginform = $('#loginform'); var forgotform = $('#forgot'); var container = $('#login_popup'); if (loginform.length > 0) { var $aForgot = $('a.forgot'); forgotform.addClass('hidden').prepend('Return to login form'); container.delegate('a.forgot', 'click', function(e){ e.preventDefault(); loginform.fadeOut(); $(this).fadeOut().closest('div').find('p:first').fadeOut(); forgotform.fadeIn().removeClass('hidden'); }); forgotform.delegate('a.return', 'click', function(e){ e.preventDefault(); $aForgot.fadeIn().closest('div').find('p:first').fadeIn(); forgotform.fadeOut(); loginform.fadeIn(); }); } $("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({ custom_markup: '
', changepicturecallback: function(){ _bsap.exec(); } }); // Product Loop (Home Page) $('.product_loop .sections .items a, #product_loop .sections .items a').hover(function(){ var $$ = $(this); var i = $$.closest('.items'); var r = i.find('.' + $$.attr('rel')); // CHANGE ACTIVE i.find('a.active').removeClass('active'); $$.addClass('active'); // CHANGE IMAGE i.find('a,img,span').addClass('none'); r.add( r.find('img') ).removeClass('none'); }); // CSS manipulation - make #page-listing left/right columns equal height var listingLeft = $('#page-listing #left'); var listingRight = $('#page-listing #right'); if (listingLeft.length > 0 && listingRight.length > 0) { listingLeft.find('.category:last').addClass('last'); // temp? var lX = parseInt(listingLeft.css('margin-top')) + parseInt(listingLeft.css('margin-bottom')) + parseInt(listingLeft.css('padding-top')) + parseInt(listingLeft.css('padding-bottom')); var rX = parseInt(listingRight.css('margin-top')) + parseInt(listingRight.css('margin-bottom')) + parseInt(listingRight.css('padding-top')) + parseInt(listingRight.css('padding-bottom')); var leftH = parseInt(listingLeft.height() + lX); var rightH = parseInt(listingRight.height() + rX); if (leftH < rightH) { listingLeft.height(rightH - rX); } else if (leftH > rightH) { listingRight.height(leftH - lX); } } // CSS manipulation - Limit height of left-hand lists if they exceed a certain height and if there are more than one var catLists = $('#left .category'); if (catLists.length > 1) { catLists.find('ul').each(function(){ if ($(this).height() > 161) { $(this).addClass('limit'); } }); } // CSS manipulation - Line up #extras left and right columns var extraLeft = $('#extras #leftcol'); var extraRight = $('#extras #rightcol'); if (extraLeft.length && extraRight.length) { if (extraRight.height() < extraLeft.height()) { extraRight.css({ 'min-height': extraLeft.height() }); if (typeof document.body.style.minHeight === "undefined") { // for ie6 extraRight.css({ 'height': extraLeft.height() }); } } else { // intended for ie6 only extraLeft.css({ 'height': extraRight.height() }); } } /*var itemDest = $('#items'); var listTarg = $('#left li a'); listTarg.each(function(){ $(this).live('click',function(e){ e.preventDefault(); alert('ok'); $.get('modules/item_block_checker', function(data){ alert(data); itemDest .css('background','#eec') .html('ok'+data); }); }); });*/ // CSS manipulation - Making dropdown