jQuery(document).ready(function(){ window.huffingtonpost_bwta_cami_track_init = {}; if(typeof HPTrack==="undefined"){HPTrack=parent.HPTrack}; if(typeof HPTrack==="undefined"){HPTrack={trackPageview:function(ga){try{console.log(ga);}catch(ex){}}}} var clicktrack = jQuery('#huffingtonpost-bwta-cami-click[href]').length != 0 ? jQuery('#huffingtonpost-bwta-cami-click').attr('href') : ''; var gatracking = '/t/a/sponsor/huffingtonpost/bwta/cami/'; try{ HPTrack.trackPageview(gatracking+'imp'); }catch(ex){} jQuery('#huffingtonpost-bwta-cami-wrapper').bind('click',function(e){ try{ HPUtil.trackerImg("http://pixel.quantserve.com/pixel/p-4azu6n0QT1rbs.gif?labels=cami.huffingtonpost.bwta.cami", document.body); }catch(ex){} if (!clicktrack) { e.preventDefault(); return false; } window.open(clicktrack.slice(0, -1),'_blank',''); e.preventDefault(); return false; }); jQuery('area').click(function(){ window.open(jQuery(this).attr('href'), '_blank', ''); return false; }); jQuery('.cami_huffpost_books_wrapper ul li>div').bind('click',function(e){ var tracking_pixel = jQuery('#huffingtonpost-bwta-cami_huffpost_books-click').attr('rel'); if(typeof(tracking_pixel) != 'undefined') jQuery('#huffingtonpost-bwta-cami_huffpost_books').after(''); try{ HPTrack.trackPageview(gatracking+'huffpost_books/'+jQuery(this).attr('rel')+'/click'); HPUtil.trackerImg("http://pixel.quantserve.com/pixel/p-4azu6n0QT1rbs.gif?labels=cami.huffingtonpost.bwta.cami", document.body); }catch(ex){} window.open(clicktrack+jQuery(this).attr('title'),'_blank',''); e.preventDefault(); return false; }); if(jQuery('#huffpost_books_scrollbar_data').length != 0) { jQuery('#huffpost_books_scrollbar_data .row').click(function(){ window.open(jQuery(this).attr('title'),'_blank',''); try{ HPTrack.trackPageview(gatracking+'huffpost_books/' + jQuery(this).attr('rel') + '/click'); }catch(ex){} }); var showed_sgc = []; var docViewTop = jQuery('#huffpost_books_scrollbar_data').scrollTop() + jQuery('#huffpost_books_scrollbar_data').offset().top; var docViewBottom = docViewTop + jQuery('#huffpost_books_scrollbar_data').height(); jQuery.each(jQuery('#huffpost_books_scrollbar_data .row'), function(){ showed_sgc[jQuery(this).attr('rel')] = false; var elemTop = jQuery(this).offset().top; var elemBottom = elemTop + jQuery(this).height(); if((elemBottom >= docViewTop) && ((elemBottom <= docViewBottom)) && (elemTop <= docViewBottom) && (elemTop >= docViewTop)) { try{ HPTrack.trackPageview(gatracking+'huffpost_books/' + jQuery(this).attr('rel') + '/imp'); }catch(ex){} showed_sgc[jQuery(this).attr('rel')] = true; } }) jQuery('#huffpost_books_scrollbar_data').scroll(function(){ jQuery.each(jQuery('#huffpost_books_scrollbar_data .row'), function(){ var elemTop = jQuery(this).offset().top; var elemBottom = elemTop + jQuery(this).height(); if((elemBottom >= docViewTop) && ((elemBottom <= docViewBottom)) && (elemTop <= docViewBottom) && (elemTop >= docViewTop)) { if(showed_sgc[jQuery(this).attr('rel')] == false) { try{ HPTrack.trackPageview(gatracking+'huffpost_books/' + jQuery(this).attr('rel') + '/imp'); }catch(ex){} showed_sgc[jQuery(this).attr('rel')] = true; } } else { showed_sgc[jQuery(this).attr('rel')] = false; } }) }); } jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper').mouseover(function(){ jQuery('#huffingtonpost-bwta-cami-wrapper').unbind('click'); }); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper').mouseleave(function(){ jQuery('#huffingtonpost-bwta-cami-wrapper').bind('click',function(e){ try{ HPUtil.trackerImg("http://pixel.quantserve.com/pixel/p-4azu6n0QT1rbs.gif?labels=cami.huffingtonpost.bwta.cami", document.body); HPTrack.trackPageview(gatracking+e.target.id+'/click'); }catch(ex){} if (!clicktrack) { e.preventDefault(); return false; } window.open(clicktrack.slice(0, -1),'_blank',''); e.preventDefault(); return false; }); }); var huffpost_books_control_click = 0; var attach_huffpost_books_control_events = function(){ try{ HPUtil.trackerImg("http://pixel.quantserve.com/pixel/p-4azu6n0QT1rbs.gif?labels=cami.huffingtonpost.bwta.cami", document.body); }catch(ex){} jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first>div').each(function(){ try{ var rel = jQuery(this).attr('rel'); if (typeof rel !== 'undefined' && rel !== false) { HPTrack.trackPageview(gatracking+'huffpost_books/'+rel+'/imp'); } }catch(ex){} }); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_next,.huffpost_books_prev').bind('click', function(){ huffpost_books_control_click++; try{ HPTrack.trackPageview(gatracking+'huffpost_books/controls/'+huffpost_books_control_click); }catch(ex){} }); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_next').die('click') jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_next').live('click', function(e){ jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_next,#huffingtonpost-bwta-cami-wrapper .huffpost_books_prev').unbind('click'); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_current').html(jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').next().attr('index')); if(jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').next().outerHeight(true) < jQuery('.cami_huffpost_books_wrapper ul li:first').outerHeight(true)){ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({marginLeft : '-=300'}, 300, function(){ var f = jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').children(':first').detach(); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').css({marginLeft : '0'}); f.appendTo('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul'); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height: jQuery('.cami_huffpost_books_wrapper ul li:first').outerHeight(true)+'px'},200,function(){ attach_huffpost_books_control_events(); }); }); }else{ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height: jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').next().outerHeight(true)+'px'},200); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({marginLeft : '-=300'}, 300, function(){ var f = jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').children(':first').detach(); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').css({marginLeft : '0'}); f.appendTo('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul'); attach_huffpost_books_control_events(); }); } }); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_prev').die('click'); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_prev').live('click', function(e){ jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_next,.huffpost_books_prev').unbind('click'); jQuery('#huffingtonpost-bwta-cami-wrapper .huffpost_books_current').html(jQuery('.cami_huffpost_books_wrapper ul li:last').attr('index')); if(jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:last').outerHeight(true) < jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').outerHeight(true)){ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').css({marginLeft : '-300px'}); var f = jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').children(':last').detach(); f.prependTo('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul'); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({marginLeft : '+=300'}, 300, function (){ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height: jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').outerHeight(true)+'px'},200,function(){ attach_huffpost_books_control_events(); }); }); }else{ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height: jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:last').outerHeight(true)+'px'},200,function(){ jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').css({marginLeft : '-300px'}); var f = jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').children(':last').detach(); f.prependTo('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul'); jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({marginLeft : '+=300'}, 300, function (){ attach_huffpost_books_control_events(); }); }); } }); }; window.huffingtonpost_bwta_cami_track_init.huffpost_books = function() { attach_huffpost_books_control_events(); } jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height: jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').outerHeight(true)+'px' },200); setTimeout("jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul').animate({height:jQuery('#huffingtonpost-bwta-cami-wrapper .cami_huffpost_books_wrapper ul li:first').outerHeight(true)+'px'},200);",1000); for (var a in window.huffingtonpost_bwta_cami_track_init) { window.huffingtonpost_bwta_cami_track_init[a](); } });