var advads171_freeze = false; function advads_load_banner(id, post_id, animation, banner_interval, banner_size, unique_banner_id) { //console.log('unique_banner_id: ' + unique_banner_id); var data_to_post = {load:1}; var products_url = "http://demo.contextazon.com/wp-content/plugins/advads171/banner_html.php?banner_id=" + id + '&post_id=' + post_id; 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; var search_method = obj.search_method_real; var advads_kws = obj.advads_kws; jQuery(".advads171_banner_unq_" + unique_banner_id).html(pop_html); /*if (advAds171Params.unbounce_enabled == 'yes') { setTimeout('advads171_force_pop()', (advAds171Params.unbounce_delay * 1000)); }*/ /*if (advAds171Params.advads171_trapped_trigger_enabled == '1' && is_advads171_loaded()) { window.onbeforeunload = advads171_trapped_trigger; }*/ jQuery(document).ready(function(){ //we want 4 steps/slides for the second banner: var real_total_steps = jQuery('.advads171_banner_unq_' + unique_banner_id + ' .ca_wrap1 .advads_ind_cell').length; if (animation == 2 || animation == 3 || animation == 4 || animation == 5 || animation == 6 || animation == 7 || animation == 10 || animation == 11) { //console.log(real_total_steps); var animation_name = 'slideOutBottom-slideInTop'; if (animation == 3) animation_name = 'slideOutTop-slideInBottom'; if (animation == 4) animation_name = 'slideOutTop-slideInTop'; if (animation == 5) animation_name = 'slideOutBottom-slideInBottom'; if (animation == 6) animation_name = 'slideOutLeft-slideInLeft'; if (animation == 7) animation_name = 'slideOutRight-slideInRight'; if (animation == 10) animation_name = 'fadeOut-fadeIn'; if (animation == 11) animation_name = 'zoomOut-zoomIn'; /*var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": animation_name}], [{"to" : "2"}, {"effect": animation_name}], [{"to" : "2"}, {"effect": animation_name}] ], [ //2 step: [{"to" : "3"}, {"effect": animation_name}], [{"to" : "3"}, {"effect": animation_name}], [{"to" : "3"}, {"effect": animation_name}] ], [ //3 step: [{"to" : "1"}, {"effect": animation_name}], [{"to" : "1"}, {"effect": animation_name}], [{"to" : "1"}, {"effect": animation_name}] ] ];*/ var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": animation_name}], [{"to" : "2"}, {"effect": animation_name}], [{"to" : "2"}, {"effect": animation_name}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": animation_name}], [{"to" : "3"}, {"effect": animation_name}], [{"to" : "3"}, {"effect": animation_name}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": animation_name}], [{"to" : "1"}, {"effect": animation_name}], [{"to" : "1"}, {"effect": animation_name}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } if (animation == 8) { var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "2"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "2"}, {"effect": "slideOutRight-slideInRight"}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "3"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "3"}, {"effect": "slideOutRight-slideInRight"}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "1"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "1"}, {"effect": "slideOutRight-slideInRight"}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } if (animation == 9) { var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": "slideOutTop-slideInBottom"}], [{"to" : "2"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "2"}, {"effect": "slideOutTop-slideInBottom"}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": "slideOutTop-slideInBottom"}], [{"to" : "3"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "3"}, {"effect": "slideOutTop-slideInBottom"}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": "slideOutTop-slideInBottom"}], [{"to" : "1"}, {"effect": "slideOutBottom-slideInTop"}], [{"to" : "1"}, {"effect": "slideOutTop-slideInBottom"}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } if (animation == 21) { var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": "zoomOutRotated-zoomInRotated"}], [{"to" : "2"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "2"}, {"effect": "slideOutBottom-slideInBottom"}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": "zoomOutRotated-zoomInRotated"}], [{"to" : "3"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "3"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": "zoomOutRotated-zoomInRotated"}], [{"to" : "1"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "1"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } if (animation == 22) { var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": "slideOutTop-slideInTop"}], [{"to" : "2"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "2"}, {"effect": "slideOutBottom-slideInBottom"}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": "slideOutTop-slideInTop"}], [{"to" : "3"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "3"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": "slideOutTop-slideInTop"}], [{"to" : "1"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "1"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } if (animation == 23) { var step_settings = [ [ //1 step: [{"to" : "2"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "2"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "2"}, {"effect": "slideOutBottom-slideInBottom"}] ] ]; if (real_total_steps == 3) { step_settings.push( [ //2 step: [{"to" : "3"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "3"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "3"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } if (real_total_steps > 1) { step_settings.push( [ //3 step: [{"to" : "1"}, {"effect": "slideOutLeft-slideInLeft"}], [{"to" : "1"}, {"effect": "slideOutRight-slideInRight"}], [{"to" : "1"}, {"effect": "slideOutBottom-slideInBottom"}] ] ); } jQuery('.advads171_banner_unq_' + unique_banner_id + ' .advads_size_init').advads_banner({ steps : step_settings, total_steps : real_total_steps, speed : banner_interval, banner_size : banner_size }); } }); advads_register_load(post_id, id, search_method, advads_kws); bind_advads171_click(id, search_method, advads_kws); } }); } jQuery(".advads171_banner").hover( function () { advads171_freeze = true; }, function () { advads171_freeze = false; } ); function advads_img_size(uniq_id) { if (typeof jQuery('.advads_prod_img_' + uniq_id).attr('data-width') === 'undefined') { //console.log('.advads_prod_img_' + uniq_id + ' width is: ' + jQuery('.advads_prod_img_' + uniq_id).css('width') ); var show_and_hide = false; //console.log(jQuery('.advads_ind_cell_' + uniq_id).css('display')); if (jQuery('.advads_ind_cell_' + uniq_id).css('display') == 'none') { show_and_hide = true; } if (show_and_hide == true) jQuery('.advads_ind_cell_' + uniq_id).css('display', 'block'); jQuery('.advads_prod_img_' + uniq_id).attr('data-width', jQuery('.advads_prod_img_' + uniq_id).css('width')); jQuery('.advads_prod_img_' + uniq_id).attr('data-height', jQuery('.advads_prod_img_' + uniq_id).css('height')); if (show_and_hide == true) jQuery('.advads_ind_cell_' + uniq_id).css('display', 'none'); } } function advads_register_load(post_id, banner_id, search_method, advads_kws) { var advads171_asin_arr = new Array(); jQuery('.advads171_banner_' + banner_id + ' a.advads_prod_imglink').each(function() { advads171_asin_arr.push(jQuery(this).attr('am_asin')); }); /*jQuery('#am_interior .prod_title_advads171_stats a').each(function() { advads171_asin_arr.push(jQuery(this).attr('am_asin')); });*/ jQuery.ajax({type: 'POST', url: 'http://demo.contextazon.com/wp-content/plugins/advads171/collect_stats.php', data: {post_id: post_id, banner_id: banner_id, asins:advads171_asin_arr.join(','), search_method: search_method, advads_kws: advads_kws, ip: '3.139.86.56' }}); } function bind_advads171_click(banner_id, search_method, advads_kws) { jQuery('.advads171_banner_' + banner_id + ' .advads171_ext_link').click( function () { jQuery.ajax({type: 'POST', url: 'http://demo.contextazon.com/wp-content/plugins/advads171/collect_stats.php', data: {advads171_collect_type: 'click', banner_id: banner_id, post_id: jQuery(this).attr('advads_post_id'), asin: jQuery(this).attr('am_asin'), search_method: search_method, advads_kws: advads_kws, ip: '3.139.86.56'}}); }); }