/**************************************************************************
Filename: common.js
Author: Caxy, Inc
URL: _ui/js/common.js

Description:
Custom JavaScript functions used on all or most templates
***************************************************************************/


$(document).ready(function(){
   // Clears the word "Search" from top Search box
       $('input#search_box').focus(function() {

     if ($("input#search_box").val() === 'Search') {$("input#search_box").val("");}

    });


    //For Faculty template, adjust col height as needed
    var f_left_side   = $("div.faculty-main-col").height();
    var f_right_side  = $("div.faculty-right-col").height();

    if ($("div.faculty-main-col").html() != null) {
      $("div.faculty-main-col").css("min-height",($("div.faculty-right-col").height()+ 4)+'px');
      $("div.faculty-right-col").css("min-height",($("div.faculty-right-col").height()+ 4)+'px');
    }




    //For Research, Academic template, adjust col height as needed
              var r_left_side   = $("div.left-bottom-box").height();
              var r_right_side  = $("div.main-col").height();

      if ($(".left-bottom-box").html() != null) {$("div.main-col").css("height",($("div.content").height()-160)+'px');}


       //For Current Students template, adjust col height as needed
          function resize_tabs() {
             if ($("div.students-main-col").html() != null) {
                        var tab_height = $("div.tabs-box-wrap").height() +325;
                        var left_side  = $("div.students-main-col").height();
                        var adjusted_height = $("div.content").height();

                      if (tab_height > left_side) {

                        $("div.students-main-col").css("height", adjusted_height+"px");

                      } else {

                        $("div.students-main-col").css("height", "auto");
                      }
              }

          }
          // Because the height is calculated at load, the first tab height cannot be determined until tab JS is executed.
          // Interval is set for 10MS which executes sizing function after tabs JS is executed.
           setTimeout(resize_tabs,"10");



    //For News Stories

      if ($("div#nav-news-events").html() != null) {

        var news_center  = $("div.main-col").height() + 122;
        var news_right   = $("div.right-col").height();
        if (news_right > news_center ) {$("div.main-col").css("height",($("div#nav-news-events").height()+122)+'px');}
     }
});

