function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

$(document).ready(function(e) {
    var pageState = gup('state');
    if (pageState == 'trial')
    {
        $('#offer_tab_container').addClass('trial');
        $('#offer_tab_container').removeClass('default');
    }

    $("a").click(function ()
    {
        var link = $(this).attr('name');
        if (link == 'follow_link')
        {
            window.open($(this).attr('href'));
            return false;
        }
    });

    $('#offer_tab .trial_tab,#offer_tab .savings_tab, .trial_content,.savings_content').css('cursor','pointer').click(function(e)
    {
        var xid = $(this).attr('id');
        var thisClass = $(this).attr('rel');
        var currentClass = $("#offer_tab_container").attr('class');

        $('#offer_tab_container').addClass(thisClass);
        $('#offer_tab_container').removeClass(currentClass);
        $('#footer').addClass('footer-lower');

        if ($('#offer_tab_container').hasClass(thisClass))
        {

            $('#savings_card_coupon').addClass('visiblity-hide');
            $('#30_day_trial_coupon').addClass('visiblity-hide');
            if ($.browser.msie)
            {
                $('#30_day_trial_coupon').css('margin-top',0);
            }
        }
        else
        {
            $('#savings_card_coupon').removeClass('visiblity-hide');
            $('#30_day_trial_coupon').removeClass('visiblity-hide');

            if ($.browser.msie)
            {
                var mtop = $('#30_day_trial_coupon').css('margin-top');
                mtop = (0);
                $('#30_day_trial_coupon').css('margin-top',mtop);
            }
        }

        e.preventDefault();
    });
});


