$(document).ready(function(){

//INITALIZE HOMEPAGE CALLOUTS***************************************************
  $('div.hp_box > div')
    .click(function() {

      var toutMap = {
        hp_copay:'/patients/about_betaseron/affording_betaseron.jsp',
        hp_treatments:'/patients/betaplus/services_support/my_beta_app.jsp',
        hp_support:'/patients/betaplus/index.jsp'
      };

      if ($(this).attr('id') == 'hp_treatments') {
    	  dcsMultiTrack('DCS.dcssip', 'www.betaseron.com','DCS.dcsuri', '/myBETAappClick.html', 'WT.ti', 'myBETAapp%20callout%20click');
      } 
      window.location = toutMap[$(this).attr('id')];
       
       
      return false;
    })
    .mouseover(function(){ $(this).css('cursor', 'pointer'); });

//INITALIZE CALLOUTS************************************************************

  $('div.content_callouts > div')
    .click(function() {

      var toutMap = {
        thin_callout:'/patients/about_betaseron/why_choose_betaseron/thinnest_needle.jsp',
        copay:'/patients/about_betaseron/affording_betaseron.jsp',
        compare_top:'/patients/about_betaseron/why_choose_betaseron/',
        why_choose: '/patients/about_betaseron/why_choose_betaseron/',
        why_choose_middle: '/patients/about_betaseron/why_choose_betaseron/',
        mentor:'/patients/betaplus/peer_mentor/index.jsp',
        compare_middle:'/patients/about_betaseron/why_choose_betaseron/',
        betaplus_tout:'/patients/betaplus/index.jsp',
        compare_bottom:'/patients/about_betaseron/why_choose_betaseron/'
      };
       window.location = toutMap[$(this).attr('id')];

      return false;
    })
    .mouseover(function(){ $(this).css('cursor', 'pointer'); });

//CLEARS SEARCH BOX*************************************************************
  $('#txt_search')
    .click(function(){
      $(this).attr('value', '');
      return false;
    })
    .blur(function(){
      if($(this).attr('value') == '') {
        $(this).attr('value','Search');
      }
    });
    $('form#search').submit(function() {
      var search_value = "Search";
      if ($('#txt_search').attr('value') == search_value) {
        return false;
      }
    });

//FIND THE SPANISH PAGE*********************************************************
$('.spanish_link').click(function(){

  var new_location = 'http://'+location.host+'/espanol'+location.pathname;
  var fallback = 'http://'+location.host+'/espanol';

  $.ajax({
    url:new_location,
    success: function(data, textStatus, XMLHttpRequest) {
      window.location = this.url;
    },
    error: function(data, textStatus, XMLHttpRequest) {
      window.location = fallback;
    }
  });

  return false;
});

//FONT RESIZER******************************************************************
  $('ul.font_resizer > li > a').click(function(){
    if($(this).attr('id') == 'font_small') {
      setActiveStyleSheet('');
    } else {
     setActiveStyleSheet($(this).attr('id'));
    }
    return false;
  });

//FAQS PAGE*********************************************************************
  if ($('body').hasClass('faqs')) {
    $('.question').click(function(){
      if ($(this).next().hasClass('currently')) {
        $('.answer.currently').slideUp('slow').removeClass('currently');
      } else {
        $('.answer.currently').slideUp('slow').removeClass('currently');
        $(this).next().slideDown('slow').addClass('currently');
      }
      return false;
    });
  }

//GTD COOKIE******************************************************************** 
  if ($.cookies.get('gtd-current-page') != null) {
    
    $('#gtd_back').show();
    $('#gtd_back').hover(
      function() {
        $('img', this).attr('src','/images/gtd_back-on.png');
      },
      function() {
        $('img', this).attr('src','/images/gtd_back-off.png');
      }
    )
    .click(function(){
      location.href=$.cookies.get('gtd-current-page');
    });
  } 

//APP LOGIN PAGE****************************************************************
  
  $('.my_app_login').click(function(){
	  dcsMultiTrack('DCS.dcssip', 'www.betaseron.com','DCS.dcsuri', '/patients/betaplus/services_support/Login.html', 'WT.ti', 'myBETAapp%20Login');
	  window.location = $(this).attr('href');
	  return false;
  });
  
//APP DOWNLOAD PAGE*************************************************************  
  $('#app_download').click(function(){
	  dcsMultiTrack('DCS.dcssip', 'www.betaseron.com','DCS.dcsuri', '/patients/betaplus/services_support/Download.html', 'WT.ti', 'myBETAapp%20Download');
	  window.location = $(this).attr('href');
	  return false;
  });
});

