﻿var IEShadows = {
  init: function () {
    $('table[rel="shadowAll"], div.storyBlock[rel="shadowAll"], div.qBlock[rel="shadowAll"], div.aQuestion[rel="shadowAll"]').each(function () {
      $(this).removeAttr('rel').wrap('<div class="shadowWrapper" rel="shadowAll" />');
      if ($(this).hasClass('storyBlock') || $(this).hasClass('qBlock') || $(this).hasClass('aQuestion')) $(this).parent().addClass('adjustWidth');
    });
    if (jQuery.browser.msie && jQuery.browser.version < 8) {
      $('ul.qButtons a[rel="shadowAll"], div.qBlock[rel="shadowAll"], div.aQuestion[rel="shadowAll"], div.qText a.editQuestion[rel="shadowAll"]').each(function () {
        $(this).removeAttr('rel').wrap('<div class="shadowWrapper" rel="shadowAll" />')
      });
    }
    $('input[rel="shadowAll"]').each(function () {
      $(this).removeAttr('rel').wrap('<div class="button" rel="shadowAll" />')
      if (jQuery.browser.msie && jQuery.browser.version < 8) {
        $(this).closest('div.button').css('width', ($(this).width()) + 'px');
      }
    });
    $('.history .block img[rel="shadowAll"], .ezhContent a[rel="shadowAll"]').each(function () {
      $(this).removeAttr('rel').wrap('<div class="button" rel="shadowAll" />')
      if (jQuery.browser.msie && jQuery.browser.version < 8 && $(this).is('.history .block img')) {
        $(this).closest('div.button').css('width', ($(this).width() + 2) + 'px');
        $(this).closest('div.button').css('height', ($(this).height() + 2) + 'px');
      }
    });
    $('.myStoryButton a[rel="shadowAll"]').each(function () {
      if (jQuery.browser.msie && jQuery.browser.version < 8) {
        $(this).removeAttr('rel').wrap('<div class="shadowWrapper" rel="shadowAll" />');
        $(this).closest('div.shadowWrapper').css('width', ($(this).width() + 20) + 'px');
        $(this).closest('div.shadowWrapper').css('height', ($(this).height() + 4) + 'px');
        if ($(this).is('.myStoryButton a')) $(this).closest('div.shadowWrapper').addClass('myBtnWrapper');
      }
    });

    var IEwrapTopLeft = '<div class="shadowTopLeft">&#160;</div>';
    var IEwrapTop = '<div class="shadowTop">&#160;</div>';
    var IEwrapTopRight = '<div class="shadowTopRight">&#160;</div>';
    var IEwrapRight = '<div class="shadowRight">&#160;</div>';
    var IEwrapBottomRight = '<div class="shadowBottomRight">&#160;</div>';
    var IEwrapBottom = '<div class="shadowBottom">&#160;</div>';
    var IEwrapBottomLeft = '<div class="shadowBottomLeft">&#160;</div>';
    var IEwrapLeft = '<div class="shadowLeft">&#160;</div>';
    $('[rel="shadowAll"]').prepend(IEwrapTopLeft + IEwrapTop + IEwrapTopRight + IEwrapRight + IEwrapBottomRight + IEwrapBottom + IEwrapBottomLeft + IEwrapLeft);
    $('[rel="shadowTop"]').prepend(IEwrapTopLeft + IEwrapTop + IEwrapTopRight + IEwrapRight + IEwrapLeft);
    $('[rel="shadowBottom"]').prepend(IEwrapRight + IEwrapBottomRight + IEwrapBottom + IEwrapBottomLeft + IEwrapLeft);
    $('[rel="shadowLeft"]').prepend(IEwrapTopLeft + IEwrapTop + IEwrapBottom + IEwrapBottomLeft + IEwrapLeft);
    $('[rel="shadowRight"]').prepend(IEwrapTop + IEwrapTopRight + IEwrapRight + IEwrapBottomRight + IEwrapBottom);
    $('#MMSubs').prepend(IEwrapRight + IEwrapBottomRight + IEwrapBottom + IEwrapBottomLeft + IEwrapLeft);
  }
}
