﻿$(document).ready(function() {
   subscribeForm();
});

function subscribeForm() {
  $(".SubscribeField").focus(function() {
      if(this.defaultValue == this.value) {
          this.value = ""
          $("#newsletterMarketing").slideToggle("slow");
      }
  });
  $(".closeform").click(function() {
      $("#newsletterMarketing").slideToggle("slow"); 
  });   
}

//function to create custom tooltips on the videoblog homepage
function toolTip() {
    //Preload the tooltip images - otherwise they don't show the first time the hover takes place
    var toolTipBck = new Image();
    toolTipBck.src = '../Images/popupRepeat.png';
    var toolTipTip = new Image();
    toolTipTip.src = '../Images/popupArrow.png';
    //grab any node with an class of tooltip
    var toolTips = $('.tooltip img');
   var on = 0;
    //onmouseover find the popup div nested inside of .tooltip and show it
    toolTips.mouseover(function() {
    var toolTipContent = $(this).parent().parent().find('.tooltipPopup');
       if(on == 0) {
       toolTipContent.show();
       on =1;
       }
       
    });
    //...and then hide it when need be
    toolTips.mouseout(function() {
       var toolTipContent = $(this).parent().parent().find('.tooltipPopup');
       toolTipContent.hide(); 
       on = 0;
    });
}

//function to hijack links on video-blog/Default.aspx
//replace the static links with links to profile.aspx plus a query string (?profileid=x) to be used by carousel.js to determine which content to load.
function hijackLinks() {
   var links = $('.tooltip a');
   for(var o=0;o<links.length; ++o) {
       links[o].href = 'profile.aspx?profileId='+o; 
   }  
} 

var selected = '';
function newsEventsTabs() {
    if(selected == '') {
   
     $('a#tab1').css('background-position','0 -26px');   
    }
    var tabs = $('#tabs a');
    $('#div1').show();
    tabs.click(function() {
         var id = this.id;
         id = id.replace('tab', '');
         if(id == 1) {
             $('a#tab1').css('background-position','0 -26px'); 
              $('a#tab2').css('background-position','0 0px'); 
            $('#div2').hide();
            $('#div1').show();
         } else if(id == 2) {
          $('a#tab2').css('background-position','0 -26px'); 
              $('a#tab1').css('background-position','0 0px'); 
            $('#div1').hide();
            $('#div2').show(); 
         }            
    });
}

function reloadVideo() {
    var tabLinks = $('#tabs li');
    tabLinks.click(function() {
        if($(this).hasClass('graduates')) {
             sendToActionScript('graduate_intro');
        } else if($(this).hasClass('gateway')) {
             sendToActionScript('gateway_intro');
        } else if($(this).hasClass('breakingthrough')) {
            sendToActionScript('breaking_intro');
        }
    });
}


function changeoutimage(imgId) {
    $(document).ready(function() {
	    if(imgId !== '') {
            var img = new Image();
            img.src ='../Images/profileImages/'+imgId;
            var alty = $('#altContent');
            alty.empty();
            alty.append(img);
        }
    });
}
var current = $('#theatreHeadGraduates');
function theatreTabs() {
  var tabs = $('ul#tabs li');
  
  tabs.click(function() {
      if($(this).hasClass('graduates')) {
      current.css('display','none');
      current = $('#theatreHeadGraduates'); 
      current.css('display','block');
        
      }  else if($(this).hasClass('gateway')) {
      $('#theatreHeadGraduates').css('display', 'none');
          current.css('display','none');
      current = $('#theatreHeadGateway'); 
      current.css('display','block');
      } else if($(this).hasClass('breakingthrough')) {
      $('#theatreHeadGraduates').css('display', 'none');
          current.css('display','none');
      current = $('#theatreHeadBreaking'); 
      current.css('display','block');
      }
  });  
}