jQuery.noConflict();
(function($) {
$.fn.replaceWith = function(replacement) {
  return this.each(function(){
    element = $(this);
    $(this)
      .after(replacement).next()
      .attr('class', element.attr('class')).attr('id',element.attr('id'))
      .html(element.html())
      .prev().remove();
  });
};
// set columns
var grid = $('.main-content-grid');
var cols = $(grid).find('.columns');
if (cols.length==2) {
    $(cols).eq(0).addClass("large-8 push-4");
    $(cols).eq(1).addClass("large-4 pull-8");
} 
else if (cols.length==3) {
    $(cols).eq(0).addClass("large-6 push-3");
    $(cols).eq(1).addClass("large-3 pull-6");
    $(cols).eq(2).addClass("large-3");
}
//set tab index on checkout forms
$('.t-commercestep form').find('input,select').each(function(i,v) {
   $(v).attr("tabindex",i);
});
    
$('.t-input').each(function(i,v) {
    var labelText = $(v).siblings('.t-label').find('label').text().replace(":","");
    $(v).find('input').attr("placeholder",labelText);
});
    
$('.t-searchstring .t-text-input').attr("placeholder","Search");

$('h3.t-attachment-header.t-freeattachments-header').text("Accessible PDF").show();    

$('#help-verification-number').addClass('reveal-modal').append('<a class="close-reveal-modal">&#215;</a>');
$('#t-cart-item-counter').insertAfter('.top-bar-section .carticon').show();
$('input.t-submit,p.t-logout a,.t-submit-acceptfree').addClass('button');
$('form').addClass('custom');
$('.t-remember,.t-latest-publist li,.search-results ol,ul.t-items,.t-register .t-field,.t-contact-us .t-field,.t-advancedsearch .t-field,div.t-collectionindex li,.t-login .t-field').addClass('container');
$('.t-userdetails .t-subscriptions, .t-userdetails .t-accountinfo').addClass('panel').addClass('center');
$('.t-offers').addClass('panel');
$('.search-results .t-nav').attr('data-magellan-expedition','fixed');
var loginhtml = $('.t-login.panel h2.t-loginbox-logged-on').html();
$('.t-login.panel h2.t-loginbox-logged-on').html('<small>'+loginhtml+'</small>').replaceWith('<h4>');
$('h1.t-offers-none').parent().parent().addClass('t-offers-none');
$('.t-toc-range-free').addClass('button').addClass('free');
$('.t-toc-range-buy').addClass('button').addClass('buy');
$('.t-submit-buynow-cart').addClass('button').addClass('buy');
$('.t-toc ul li').each(function() {
    $(this).find('.t-toc-range-download:first').show();
});
$('.t-toc-logical-pageno:first').parents('.t-toc').addClass('t-logical-on');
$('.t-logical-pageno:first').parents('ol.container').addClass('t-logical-on');
$('.t-commercestep.t-cvv2 a').each(function(i,v) {
   $(v).attr("onclick","");
   $(v).attr("href","whatsthis");
   $(v).addClass('hide-for-small');
   $(v).on("click",function() {
       $('#help-verification-number').foundation('reveal', 'open');
       return false;
   });
   return false;
});
$('input[value="Revise purchase details"]').removeClass('button').addClass('revise-purchase');
$(document).foundation();
$('.main-content-grid').css("visibility","visible");
})(jQuery); 
