var clickedCashback;
$(function(){
if(!isIE9){
var zero = new ZeroClipboard($(".copy-code"));
}
clickedCashback = $("#store-banner .store-cashback").length > 0 ? $("#store-banner .store-cashback").html() : '';
$(".store-reveal").click(function(){
if(!isLoggedIn){
var title = $(this).find('.store-affiliate-title p').html();
var desc = $(this).find('.store-affiliate-description').html();
var expiry = $(this).find('.store-affiliate-expiry p').html();
var code = $(this).find('.store-affiliate').attr('data-code');
var link = $(this).attr('data-link');
var popup = $("#modalRevealCode");
if(code.length > 0){
popup.find('div.store-voucher, p.store-voucher').show();
popup.find('.modal-body p.paste').show();
}else{
popup.find('div.store-voucher, p.store-voucher').hide();
popup.find('.modal-body p.paste').hide();
}
var five = desc;
var storeamount = $(this).parent().parent().find('.store-amount.hidden-xs');
if(storeamount.length > 0){
clickedCashback = storeamount.data('true-value') + '% Cashback';
}
//console.log(clickedCashback);
if(clickedCashback !== '') five = 'Join us now & get '+clickedCashback+' FREE.
Try it, it\'s on us! =)';
//alert(five);
popup.find('.modal-header .modal-title').html(title);
popup.find('.modal-body .h-heading-2').html(expiry);
popup.find('.modal-body .h-heading-2b').html(five);
popup.find('.modal-body input').val(code);
popup.find('.modal-body .invi').text(code);
popup.find('a.continue-link').attr('href', link);
popup.find('button.copy-btn').html("Copy");
$('#modalRevealCode').modal('show');
}
});
$('.store-body').click(function(){
$(this).parent().parent().find('.store-affiliate-box a').click();
});
$("#modalRevealCode button.copy-btn").click(function(){
$(this).addClass('disabled').html("✔ Copied");
});
$('.termsexclusions a.btn-green').click(function(e){
e.preventDefault();
var aTag = $($(this).attr('href'));
$('html, body').animate({scrollTop: aTag.offset().top - 30},'fast');
});
/* start newer scripts */
$(".merch-reveal").click(function(){
var entry = $(this).parent().parent().parent();
if(!isLoggedIn){
var title = entry.find('.h-affiliate-title').html();
var desc = entry.find('p.merch-affiliate-description').html();
var expiry = entry.find('p.merch-affiliate-expiry').html();
var code = entry.attr('data-code');
var link = $(this).attr('data-link');
var popup = $("#modalRevealCode");
if(code.length > 0){
popup.find('div.store-voucher, p.store-voucher').show();
popup.find('.modal-body p.paste').show();
}else{
popup.find('div.store-voucher, p.store-voucher').hide();
popup.find('.modal-body p.paste').hide();
}
popup.find('.modal-header .modal-title').html(title);
popup.find('.modal-body .h-heading-2').html(expiry);
popup.find('.modal-body .h-heading-2b').html(desc);
popup.find('.modal-body input').val(code);
popup.find('.modal-body .copy-code').attr('data-clipboard-text', code);
popup.find('.modal-body .invi').text(code);
popup.find('a.continue-link').attr('href', link);
popup.find('button.copy-btn').html("Copy");
$('#modalRevealCode').modal('show');
}
});
$('.read-more.hidden-xs').click(function(){
$('.h-desc').toggleClass('faded-1').toggleClass('faded-cancel');
$(this).find('span').toggleClass('hide');
});
$('.faded-2').click(function(){
$(this).removeClass('faded-2').addClass('faded-cancel');
});
$('.blox.colLeft .merchant-notes .ex').click(function(){
$(this).toggleClass('ex-expanded').toggleClass('ex-collapsed');
$(this).parent().parent().find('.merchant-notes-content').toggleClass('hide');
});
$('.blox.colRight .merchant-notes .row-heading').click(function(){
$(this).find('.ex').toggleClass('ex-expanded').toggleClass('ex-collapsed');
$(this).parent().find('.merchant-notes-content').toggleClass('hide');
});
$('#merchantHeader .headerDetails a.merch-modal-show').click(function(){
$('.blox.colLeft .current-deals .merch-affiliate:first-child .get-cashback').trigger('click');
});
$('.moreDeals').click(function(){
var i = 0;
$('.merch-affiliate.hide:not(.expired)').each(function(){
if(i < 5) $(this).removeClass('hide');
i++;
if($('.merch-affiliate.hide:not(.expired)').length === 0){
$('.moreDeals').remove();
$('.pastDeals').removeClass('hide');
}
});
});
$('.pastDeals a').click(function(){
$('.current-deals .merch-affiliate.expired').removeClass('hide');
$('.pastDeals').remove();
});
/* end newer scripts */
});