﻿var itemCounter = 0;

$(document).ready(function () {

	if($(".tabs").length != 0) $(".tabs").tabs();

  TextBoxSwitch($("input.txtSearchBox"), "Search");

  // Increase Font Size
  $(".fontSizerLarger").click(function () {
    //H1
    var currentFontSize = $('H1').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 1.2;
    $('H1').css('font-size', newFontSize);

    //Tabbed page
    var currentFontSize = $('.videoDescription').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 1.2;
    $('.videoDescription').css('font-size', newFontSize);
    var currentFontSize = $('#tab-transcript').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 1.2;
    $('#tab-transcript').css('font-size', newFontSize);
    var currentFontSize = $('.resize').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 1.2;
    $('.resize').css('font-size', newFontSize);
    return false;
  });

  // Decrease Font Size
  $(".fontSizerSmaller").click(function () {
    //H1
    var currentFontSize = $('H1').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 0.8;
    $('H1').css('font-size', newFontSize);

    //Tabbed page
    var currentFontSize = $('.videoDescription').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 0.8;
    $('.videoDescription').css('font-size', newFontSize);
    var currentFontSize = $('#tab-transcript').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 0.8;
    $('#tab-transcript').css('font-size', newFontSize);
    var currentFontSize = $('.resize').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum * 0.8;
    $('.resize').css('font-size', newFontSize);
    return false;
  });

	//    If IE, add a div to each .box for a drop shadow effect
	if ($.browser.msie) {
	  $('.box').each(function () {
		itemCounter++;
		//    Help from http://placenamehere.com/article/384/CSS3BoxShadowinInternetExplorerBlurShadow
		var itemPos = $(this).position();
		$(this).append('<div class="IEShadow IEShadow' + itemCounter + '"></div>');
		$('.IEShadow' + itemCounter).height($(this).height());
	  });
	}

	if($('#videoPopup').length != 0) $('#videoPopup').jqm({ onHide: unloadVideo });

	$(".PopupVideo").click(function () {
    var thisVideoPath = $(this).attr("href");
    loadVideo(thisVideoPath);
    return false;
  });


  function unloadVideo(hash) {
    hash.w.hide();
    hash.o.remove();
    swfobject.removeSWF("flashVideo");
    $("#fvContainer").html('<div id="flashVideo"></div>');
  }
});


// Search text box value switching
function TextBoxSwitch(thisObject, defaultText) {
  var fieldTextBox = thisObject;
  var fieldTextBoxDefault = defaultText;
  fieldTextBox.val(fieldTextBoxDefault);
  fieldTextBox.focus(function () {
    if (fieldTextBox.attr('value') == fieldTextBoxDefault) {
      fieldTextBox.attr('value', '').removeClass('Edited');
    } else {
      fieldTextBox.addClass('Edited');
    };
  });
  fieldTextBox.blur(function () {
    if (fieldTextBox.attr('value') == '') {
      fieldTextBox.attr('value', fieldTextBoxDefault).removeClass('Edited');
    } else {
      fieldTextBox.addClass('Edited');
    };
  });
}

