Core.settings({site:'research',
plugins:'/research/js/plugins'
			  });

(function($){

var Research = {
        ondomready:function() {
         Research.links();
         Research.tablestripes();
         Research.tablestripes2();
         Research.topnav();
         Research.subnav();
         Research.tabnav();
         Research.expandables();
         Research.facsearch();
         //Research.fixdevlinks();
         //Research.fixlinks();
         Research.otherexpandables();        
         Core.email_obfuscation();
         $("hr").replaceWith('<div class="hr"></div>');
    },
     

    facsearch: function() {
        $("#facfind_text").focus(function(){
            if ($(this).val() == ' -- type name here -- ') { $(this).val('') }
         });
    },
	
    
    fixdevlinks: function() {
      return;
      
      if (!/(webstage|webdev)/.test(document.location.href)) { return }
      
      $("a,form").each(function(){
        var $a = $(this);
        if ($a.attr('href')) {
           //if (!/bhr/.test($a.attr('href'))) {
              $a.attr('href',$a.attr('href').replace('pine.hbs.edu','stage.hbs.edu:7015'));
              $a.attr('href',$a.attr('href').replace('drfd.hbs.edu','drfd-stage.hbs.edu'));
           //}
        }
        if ($a.attr('action')) {
           //if (!/bhr/.test($a.attr('action'))) {
              $a.attr('action',$a.attr('action').replace('pine.hbs.edu','stage.hbs.edu:7015'));
              $a.attr('action',$a.attr('action').replace('drfd.hbs.edu','drfd-stage.hbs.edu'));
           //}
        }
      });
      
    },
   	
    fixlinks: function() {
       $("a[href^='http://pine.hbs.edu/external/facPersonalShow.do?email']").each(function(){
          this.href = this.href.replace("http://pine.hbs.edu/external/facPersonalShow.do?email",
                                        "http://drfd.hbs.edu/fit/public/facultyInfo.do?facInfo=ovr&facEmId") + '%40hbs.edu';
       });
    },
	
    links: function() {   
        if(!/database/.test(location.href)) {
          $("#content a,#sidebar a").each(function() {
             // comment add .ext class
             $a = $(this);
             var badie = $.browser.msie && parseInt($.browser.version.substr(0,1)) < 8;
             if (this.href && !/mailto/.test(this.href)) {
                if (! /hbs.edu/.test(this.href)) {$a.addClass("ext");}
                if (/video2.harvard.edu/.test(this.href)) {$a.removeClass("ext");}
                if (/hbsp.harvard.edu/.test(this.href)) {$a.removeClass("ext");}
                if (/harvardbusiness.org/.test(this.href)) {$a.removeClass("ext");} 
				 if (/hbr.org/.test(this.href)) {$a.removeClass("ext");} 
                if ( /.pdf$/.test(this.href)) {
                        $a.addClass('pdf');
             		$a.append('<span><img src="http://www.hbs.edu/shared/images/pdf-popout.png" border="0" alt="PDF Document"/></span>');
                }
             }
             if ($a.hasClass("new_window")){
                 $(this).click(function(){
                      Core.new_window(this);
                      return false;
                 });
             }
             
             if ($a.hasClass('link') && $a.hasClass('ext')) { // only for DRFD home page
                $a.removeClass('link');
             }
			 
             
             
             if ($a.hasClass('pdf') && badie) {
                //$a.removeClass('pdf');
                //$a.append(' [pdf]');
             }
             if ($a.hasClass('ext') && badie) {
                $a.removeClass('ext');
                //$a.append(' [pdf]');
             }
         });
       }
    },
	
	// function for subnav pdfs
	
   /* subpdf: function() {   
        if(!/database/.test(location.href)) {
           $("#subnav a").each(function() {
          // comment add .ext class
          $a = $(this);
          if (this.href && !/mailto/.test(this.href)) {
             if ( /.pdf$/.test(this.href)) {$a.addClass('pdf')}
          }
          });
       }
    },	*/
	
	
    tablestripes: function() {
		$("#seminar-page tr:odd, #curriculum-page tr:odd").addClass("alt");
		
		
		//if (!document.getElementById("seminar-page")) return;
         // $("tr:odd").addClass("alt");
    }, 	
    tablestripes2: function() {
		//if (!document.getElementById("curriculum-page")) return;
        //  $("tr:odd").addClass("alt");
    },
	
    fixfonts: function() {
		  var ft = $('#tabbed-content');
		  var html = ft.html();
		  html = html.replace(/font-family/ig, "");
		  html = html.replace(/font-size/ig, ""); 
		  html = html.replace(/<font face="Times New Roman" size="3">/ig, ""); 
		  html = html.replace(/<\/?font>/ig, "");
		  ft.html(html);
    },
	
      /*
     * Add an 'on' class to the top nav
     */
     
    topnav: function() {
        function sethere(id) {
            var a = document.getElementById(id+'-nav');
            if (!a){return};
            a.parentNode.className += ' on';
            a.className += ' on';
        }
        var loc = document.location.href;
        if (loc.indexOf('/research/faculty/') > -1) { sethere('faculty'); } 
        else if (loc.indexOf('/research/publications/') > -1) { sethere('publications'); } 
        else if (loc.indexOf('/units/') > -1) { sethere('units'); } 
        else if ($("body").hasClass("home")) { sethere('home'); } 
        
    },
	

	

    /*
     * Add an 'on' class to 'subnav'
     */

    subnav: function() {
         $("#subnav a:thisurl").addClass("on");
    },      
    
    tabnav: function() {
         $("#tabs a:thisurl").addClass("on");
         $("#tabs a[@class='on']").parent('td').addClass("selected");  
    },    
   
   
    expandables: function() {
         $("#subnav ul.expandable>li>ul").addClass("closed"); 
         $("#subnav ul.expandable>li").each(function() {
             if ($(this).find("ul").size() == 0) {
                 $(this).addClass("nochildren");
             }
          })
         $("#subnav ul.expandable>li>a").click(function() {
          if ($(this).parent().find("ul").size() > 0) {
              $(this).parent().children().toggleClass("closed");
              $(this).parent().toggleClass("open");
              return false;
          } else {
              return true;
          }
        });     
         
         $("#subnav li.expandable>ul").addClass("closed");
         $("#subnav li.expandable").click(function() {
          $("#subnav li.expandable>ul").toggleClass("closed"); 
          return false;
        });     
         
        $("#subnav ul a[@class='on']").parent('ul').removeClass("closed"); 
    },    
   
    otherexpandables: function() {
        $("#content dl.expandable dd").addClass("closed");
        $("#content dl.expandable dt").click(function() {
          $(this).toggleClass("open");
          $(this).next().toggleClass("closed");
          return false;
        });
   
        $("#sidebar dl.expandable dd").addClass("closed");
        $("#sidebar dl.expandable dt").click(function() {
          $(this).toggleClass("open");
          $(this).next().toggleClass("closed");
          return false;
        });  
   
        $("ul.expands li a.more").click(function(){
          $(this).parent().parent().find("span").toggle();
          $("li").toggleClass("show");
          return false;
        })
    }
     
}


window.Research = Research;

$(document).ready(Research.ondomready);

})(jQuery)





function new_window(href) {
  Core.new_window(href);
  return false;
}
