var posX;
var posY;
var xdiff;
var ydiff;
var xold;
var yold;
var am_loaded = false;
var exittr_fired = false;
var wpb_audio_loaded = false;
var exittr_search_method_real = '0';
var exittr_kws = '';
var exittr_StopPop = false;
function exittr_trapped_trigger(e) {
if(exittr_StopPop == false){
var message = wpBounceParams.exittr_trapped_trigger_msg,
e = e || window.event;
bind_wpb_click();
style_exittr_pop();
jQuery("#am_popbox").css('display', 'block');
jQuery('#wpb_am_trigger').hide();
exittr_fired = true;
align_product_images();
register_pop(wpBounceParams.post_id);
// For IE and Firefox
if (e) {
alert(message);
e.returnValue = message;
}
// For Safari
return message;
}
};
jQuery(document).ready(function(){
//fix sensor height
jQuery('#wpb_am_trigger').css('height', wpBounceParams.sensor_height + 'px');
jQuery('#wpb_am_trigger img').css('height', wpBounceParams.sensor_height + 'px');
jQuery('#am_interior').css('width', wpBounceParams.exittr_pop_width + 'px');
jQuery('#am_interior').css('height', wpBounceParams.exittr_pop_height + 'px');
jQuery('#am_interior').css('border-width', wpBounceParams.exittr_border_width + 'px');
jQuery('#am_interior').css('border-style', wpBounceParams.exittr_border_type);
jQuery('#am_interior').css('border-color', wpBounceParams.exittr_border_color);
if (wpBounceParams.exittr_mouse_trigger_disabled != 1)
{
jQuery('#wpb_am_trigger').mouseover(function() {
if (am_loaded && exittr_fired == false && is_wpbounce_loaded())
{
style_exittr_pop();
jQuery("#am_popbox").fadeIn(200, function () {
align_product_images();
bind_wpb_click();
register_pop(wpBounceParams.post_id);
if (window.exittr_play_audio) exittr_play_audio();
});
jQuery('#wpb_am_trigger').hide();
exittr_fired = true;
}
});
}
jQuery(".close").click(function(){
jQuery("#am_popbox").hide();
});
var extra_uri = '';
if (wpBounceParams.exittr_is_virtual == 'yes')
{
extra_uri = extra_uri + '&is_virtual=yes&s=' + wpBounceParams.s;
}
//jQuery("#am_interior").load("https://allpiggybanks.com/wp-content/plugins/wpbounce/ampop_results.php?post_id=" + wpBounceParams.post_id + '&tpl=' + wpBounceParams.exittr_tpl_key + extra_uri, { }, function () {
var data_to_post = {load:1};
var products_url = "https://allpiggybanks.com/wp-content/plugins/wpbounce/ampop_results.php?post_id=" + wpBounceParams.post_id + '&tpl=' + wpBounceParams.exittr_tpl_key + extra_uri;
if (wpBounceParams.exittr_source == 1)
{
products_url = "https://allpiggybanks.com/wp-content/plugins/wpbounce/epnpop_results.php?post_id=" + wpBounceParams.post_id + '&tpl=' + wpBounceParams.exittr_tpl_key + extra_uri;
}
if (wpBounceParams.exittr_source != 999)
{
jQuery.ajax({
url: products_url,
type: "POST",
data: data_to_post,
success: function(data) {
//var obj = jQuery.parseJSON(data);
var obj = JSON.parse(data);
var pop_html = obj.html;
exittr_search_method_real = obj.exittr_search_method_real;
exittr_kws = obj.exittr_kws;
jQuery("#am_interior").html(pop_html);
if (obj.jscripts != undefined && obj.jscripts.length > 0)
{
jQuery("#exittr_js_content").html("");
}
am_loaded = true;
if (wpBounceParams.unbounce_enabled == 'yes')
{
setTimeout('exittr_force_pop()', (wpBounceParams.unbounce_delay * 1000));
}
if (wpBounceParams.exittr_trapped_trigger_enabled == '1' && is_wpbounce_loaded())
{
window.onbeforeunload = exittr_trapped_trigger;
}
}
});
}
//disable links
var a = document.getElementsByTagName('A');
for (var i = 0; i < a.length; i++) {
exittr_addClickEvent(a,i, function(){ exittr_StopPop=true; });
}
//disable form submit
var f = document.getElementsByTagName('FORM');
for (var i=0;i 0 || jQuery('.amzn_buy_now_large_wpb_text').length > 0) && wpBounceParams.exittr_amzn_button_img != '' && wpBounceParams.exittr_amzn_button_img != ' ') || ((jQuery('.epn_buy_now_wpb_text').length > 0 || jQuery('.epn_buy_now_large_wpb_text').length > 0) && wpBounceParams.exittr_epn_button_img != '' && wpBounceParams.exittr_epn_button_img != ' ') || ((jQuery('.epn_bid_now_wpb_text').length > 0 || jQuery('.epn_bid_now_large_wpb_text').length > 0) && wpBounceParams.exittr_epn_bid_button_img != '' && wpBounceParams.exittr_epn_bid_button_img != ' '))
{
jQuery('.amzn_buy_now_wpb_text, .amzn_buy_now_large_wpb_text').html('').addClass('wpb_image_button_link');
jQuery('.epn_buy_now_wpb_text, .epn_buy_now_large_wpb_text').html('').addClass('wpb_image_button_link');
jQuery('.epn_bid_now_wpb_text, .epn_bid_now_large_wpb_text').html('').addClass('wpb_image_button_link');
}
else
{
jQuery('.buy_now_wpb_text, .buy_now_large_wpb_text').removeClass('wpb_image_button_link');
jQuery('.buy_now_wpb_text, .buy_now_large_wpb_text').text(wpBounceParams.exittr_button_text);
//button css
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('color', wpBounceParams.exittr_button_text_color);
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background-color', wpBounceParams.exittr_button_color_bottom);
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', wpBounceParams.exittr_button_color_bottom);
if (jQuery.browser.mozilla && jQuery.browser.version > 3.5)
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', '-moz-linear-gradient(top, '+ wpBounceParams.exittr_button_color_top +' 1%, '+ wpBounceParams.exittr_button_color_middle+' 50%, '+wpBounceParams.exittr_button_color_middle+' 52%, '+wpBounceParams.exittr_button_color_bottom+' 100%)');
}
else if (jQuery.browser.opera && jQuery.browser.version > 11.1)
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', '-o-linear-gradient(top, '+ wpBounceParams.exittr_button_color_top+' 1%,'+ wpBounceParams.exittr_button_color_middle+' 50%,'+wpBounceParams.exittr_button_color_middle+' 52%,'+wpBounceParams.exittr_button_color_bottom+' 100%)');
}
else if ((jQuery.browser.chrome && jQuery.browser.version < 10) || (jQuery.browser.safari && (jQuery.browser.version < 5.1 && jQuery.browser.version > 3.9)))
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', '-webkit-gradient(linear, left top, left bottom, color-stop(1%,'+ wpBounceParams.exittr_button_color_top+'), color-stop(50%,'+ wpBounceParams.exittr_button_color_middle+'), color-stop(52%,'+ wpBounceParams.exittr_button_color_middle +'), color-stop(100%,'+ wpBounceParams.exittr_button_color_bottom +'))');
}
else if ((jQuery.browser.chrome && jQuery.browser.version > 9.9) || (jQuery.browser.safari && jQuery.browser.version > 5) || jQuery.browser.webkit)
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', '-webkit-linear-gradient(top, '+ wpBounceParams.exittr_button_color_top +' 1%,'+ wpBounceParams.exittr_button_color_middle +' 50%,'+ wpBounceParams.exittr_button_color_middle +' 52%,'+ wpBounceParams.exittr_button_color_bottom +' 100%)');
}
else if ((jQuery.browser.msie && jQuery.browser.version > 9.9))
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', '-ms-linear-gradient(top, '+ wpBounceParams.exittr_button_color_top +' 1%,'+ wpBounceParams.exittr_button_color_middle +' 50%,'+ wpBounceParams.exittr_button_color_middle +' 52%,'+ wpBounceParams.exittr_button_color_bottom +' 100%)');
}
else if ((jQuery.browser.msie && jQuery.browser.version > 5.9 && jQuery.browser.version < 10))
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('filter', 'progid:DXImageTransform.Microsoft.gradient( startColorstr=\''+ wpBounceParams.exittr_button_color_top +'\', endColorstr=\''+ wpBounceParams.exittr_button_color_bottom +'\',GradientType=0 )');
}
else
{
jQuery('.buy_now_wpb, .buy_now_large_wpb').css('background', 'linear-gradient(top, '+ wpBounceParams.exittr_button_color_top +' 1%,'+ wpBounceParams.exittr_button_color_middle +' 50%,'+ wpBounceParams.exittr_button_color_middle+' 52%,'+ wpBounceParams.exittr_button_color_bottom +' 100%)');
}
}
}
}
var wpb_animation_count = 0;
function wpb_animate_msg_step()
{
wpb_animation_count = wpb_animation_count + 1;
if (wpb_animation_count < 5)
{
jQuery('.pop_title_wpb').animate({opacity:.1},300).animate({opacity:1},200, function () { wpb_animate_msg_step(); });
}
}
function register_pop(post_id)
{
if (wpBounceParams.exittr_message_flash == '1')
{
wpb_animation_count = 0;
wpb_animate_msg_step();
}
var exittr_asin_arr = new Array();
jQuery('#am_interior .prod_title_wpb a').each(function() {
exittr_asin_arr.push(jQuery(this).attr('am_asin'));
});
jQuery('#am_interior .prod_title_wpb_stats a').each(function() {
exittr_asin_arr.push(jQuery(this).attr('am_asin'));
});
jQuery.ajax({type: 'POST', url: 'https://allpiggybanks.com/wp-content/plugins/wpbounce/collect_stats.php', data: {post_id: post_id, msg_key: wpBounceParams.exittr_message_key, tpl_key:wpBounceParams.exittr_tpl_key, asins:exittr_asin_arr.join(','), source:wpBounceParams.exittr_source, exittr_search_method_real: exittr_search_method_real, exittr_kws: exittr_kws}});
}
function bind_wpb_click()
{
jQuery('.exittr_ext_link').click( function ()
{
jQuery.ajax({type: 'POST', url: 'https://allpiggybanks.com/wp-content/plugins/wpbounce/collect_stats.php', data: {exittr_collect_type: 'click', post_id: wpBounceParams.post_id, msg_key: wpBounceParams.exittr_message_key, tpl_key:wpBounceParams.exittr_tpl_key, asin: jQuery(this).attr('am_asin'), exittr_search_method_real: exittr_search_method_real, exittr_kws: exittr_kws}});
});
if (wpBounceParams.exittr_track_links == 1)
{
jQuery('.wpb_custom_html_wrap a').click( function ()
{
jQuery.ajax({type: 'POST', url: 'https://allpiggybanks.com/wp-content/plugins/wpbounce/collect_stats.php', data: {exittr_collect_type: 'click', post_id: wpBounceParams.post_id, msg_key: wpBounceParams.exittr_message_key, tpl_key:wpBounceParams.exittr_tpl_key, exittr_search_method_real: exittr_search_method_real, exittr_kws: exittr_kws}});
});
}
if (wpBounceParams.exittr_track_submits == 1)
{
jQuery('.wpb_custom_html_wrap form').submit( function ()
{
jQuery.ajax({type: 'POST', url: 'https://allpiggybanks.com/wp-content/plugins/wpbounce/collect_stats.php', data: {exittr_collect_type: 'click', post_id: wpBounceParams.post_id, msg_key: wpBounceParams.exittr_message_key, tpl_key:wpBounceParams.exittr_tpl_key, exittr_search_method_real: exittr_search_method_real, exittr_kws: exittr_kws}});
});
}
}
function align_product_images()
{
if (jQuery('.prod_img_link_epn').length > 0)
{
jQuery('.prod_img_link_epn img').each(function() {
var img_height = jQuery(this).height();
if (img_height == 0 || img_height == undefined)
{
img_height = 140;
}
if (jQuery(this).hasClass('epn_image_oneprod'))
{
var margin_top = Math.floor((270 - img_height) / 2);
}
else
{
var margin_top = Math.floor((190 - img_height) / 2);
}
jQuery(this).css('margin-top', margin_top);
});
}
jQuery('.prod_img_link_epn img').css('visibility', 'visible');
}
function is_wpbounce_loaded()
{
var am_interior_html = jQuery("#am_interior").html();
if (am_interior_html == 'error' || am_interior_html == '' || am_interior_html == '' || jQuery('#am_interior .pop_title_wpb').length == 0)
{
return false;
}
else
{
return true;
}
}