// jQuery Common Scripts // jQuery script to control display of pcmag header product guide nav flyout $(document).ready(function() { $('li.prodGuide a#more' ).hover ( function(e) { $('div#w_flyout').show('fast',function() { //$('div#w_flyout').addClass('clickable'); $('div#w_flyout').hover ( function(e) { $('div#w_flyout').show() }, function(e) { $('div#w_flyout').hide(); } ); }); }, function(e) { $('div#w_flyout').hide(); } ); }); // Move splashshot ribbon to value set in class attribute of #w_splashshot // class = "pnum"+position parameter. Set in ziffsplash tag. // Else left it where it is $(document).ready(function(){ if ($('#w_splashshotRibbon')) { if ($('#w_splashshotRibbon').attr('class')) { var pnum = $('#w_splashshotRibbon').attr('class'); var paraPosition = (pnum.substr(4, pnum.length)-1 ); var pCount = $('.articleCopy p').length; // alert ('pnum is: '+pnum+'\n paraPosition is: '+paraPosition+'\n pCount is: '+pCount); if (pCount > paraPosition) { $('#w_splashshotRibbon').insertAfter($('.articleCopy p:eq('+paraPosition+')')); } } } }); // jQuery Product Grid Scripts // Controls Striping of Specs section $(document).ready(function() { if ($('table.productCompare')) { $('table.productCompare tbody.specs tr:odd').addClass('odd'); $('table.productCompare tbody.specs tr:even').addClass('even'); } }); // Controls Toggle of Specs and Benchmarking Display $(document).ready(function() { var toggleMinus = '/images/bullet_toggle_minus.png'; var togglePlus = '/images/bullet_toggle_plus.png'; // toggle subhead var $subHead = $('table.productCompare tbody.specs th.rowHeader'); //$subHead.prepend('collapse this section'); $('img', $subHead).addClass('clickable') .click(function() { var toggleSrc = $(this).attr('src'); if ( toggleSrc == toggleMinus ) { $(this).attr('src', togglePlus) .parents('tr').siblings().fadeOut('fast') } else { $(this).attr('src', toggleMinus) .parents('tr').siblings().fadeIn('fast'); }; }); }); $(document).ready(function() { // Toggles "Restore Columns" button when columns have been deleted $('div.restoreColumn').css('display','none'); $('div.restoreColumn').addClass('clickable restoreColumn') .click(function() { $('table.productCompare td').fadeIn('fast'); $('table.productCompare th').fadeIn('fast'); $('div.restoreColumn').fadeOut('fast'); }); // Controls collapsing of product columns var toggleMinus = '../images/minus.png'; $('table.productCompare').each(function() { var $table = $(this); $('th.toggleColumn', $table).each(function(column) { $('img', $(this)).addClass('clickable') .click(function() { var toggleSrc = $(this).attr('src'); if ( toggleSrc == toggleMinus ) { // hide // $(this).attr('src', togglePlus); $(this).parent('th').fadeOut('fast'); $table.find('th').filter(':nth-child(' + (column + 1) + ')').fadeOut('fast'); $table.find('td').filter(':nth-child(' + (column + 1) + ')').fadeOut('fast'); $('div.restoreColumn').fadeIn('fast'); } }); }); }); }); $(document).ready(function() { $('.search-box').focus(function () { $(this).attr('value','') .css('color','#000'); }); $('.search-box').blur(function () { var searchContents = $(this).attr('value'); if (searchContents == '' && searchContents != 'SEARCH') { $(this).attr('value','SEARCH') .css('color','#ccc'); } }); }); $(document).ready(function () { $('ul#subscribe-mega-drop').hide(); $('div.subscribe-box').addClass('clickable').hover ( function() { var anchor = $('div.subscribe-box a#subscribe-nav').position(); var leftX = anchor.left; var topY = anchor.top; // alert ('top: ' + topY + ' left: ' + leftX); $('ul#subscribe-mega-drop') .css({'position':'absolute','left':leftX-198 +'px', 'top':topY+17+'px'}) .show(); $('ul#subscribe-mega-drop li').hover ( function() { $(this).css('backgroundColor','#cff'); }, function() { $(this).css('backgroundColor','#fff'); } ) }, function() { $('ul#subscribe-mega-drop').hide(); } ) }); $(document).ready(function() { $('div#nav-drop').hide(); $('div.nav-drop-item').hide(); $('ul.nav li').hover ( function() { $('ul.nav li').css('backgroundColor', '#000'); $(this).css('backgroundColor', '#4d4d4f'); var showDropDown = $(this).attr('class'); if (showDropDown.indexOf('nav-item')!= -1) { var showWhat = $(this).attr('id'); var anchor = $('li#show-reviews a').position(); var topY = anchor.top; var midpoint = $('body').width() / 2; var leftX = midpoint - 335; jQuery.each(jQuery.browser, function(i) { if($.browser.msie){ leftX = midpoint-339; } else if ($.browser.safari) { leftX = midpoint-329; }else { leftX = midpoint-334; } }); $('div#nav-drop') .css({'position':'absolute','top':topY+83 + 'px', 'left':leftX+'px'}) .show(); if (showWhat == "show-reviews" ) { $('li#show-reviews').css('background-color', '#4d4d4f'); $('div#reviews').show(); $('div#news').hide(); } else { $('li#show-news').css('background-color', '#4d4d4f'); $('div#news').show(); $('div#reviews').hide(); } $('ul.nav-drop-list li').hover ( function() { $(this).css('backgroundColor', '#ccffff'); }, function() { $(this).css('backgroundColor', '#fff'); } ) } else { $('div#nav-drop').hide(); $(this).css('backgroundColor', '#000'); } }, function() { //$(this).css('backgroundColor', '#000'); $('div#nav-drop').hide(); } ); $('div#nav-drop').hover ( function() { $(this).show(); }, function() { $(this).hide(); $('ul.nav li').css('backgroundColor', '#000'); } ) $('ul.nav-drop-list li').hover ( function() { $(this).css('backgroundColor', '#ccffff'); }, function() { $(this).css('backgroundColor', '#fff'); } ) });