// Cufon Replacements
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('.frontpage_menu_bar ul li a',{hover: 'true'});
Cufon.replace('.menu_bar ul li a',{hover: 'true'});
Cufon.replace('h1');

function handler(event){
  var $target = $(event.target);
  if( $target.is("li") ) {
    $target.children().toggle();
  }
}

jQuery(document).ready(function($){
    //Site URL Base
    //var siteUrl = "http://128.100.94.81/staff/dev/doe_site";
    var siteUrl = "http://www.doe.utoronto.ca";
    
    // copyright info
    var footer = "";
    footer += "Last updated on ";
    var theDate = document.lastModified;
    theDate = theDate.substr(0, 10);
    footer += theDate;
    footer += ".<br/>For comments please go to<br/>";
    footer += "<a href=\"" + siteUrl + "/pages/contact.php\">Contact Us</a>.<br\/>";
    footer += "&copy;2011, The Dictionary of Old English, University of Toronto.";
    
    $('#copyright_info').html(footer);
    
    // side bar
    var elementName = $('.element').attr('id');
    $('.element').load( siteUrl + "/elements/" + elementName + '.html' , function(){ Cufon.replace('.menu_bar ul li a',{hover: 'true'});});
    
    //Tooltip
    $('#recaptcha').tooltip({
	effect: 'hide'
    });
    
    $('[title]').tooltip({
	effect: 'fade'
    });
    
    
    $('#sample_entry .info').hover(function(event){
	$(this).addClass('hovered');
    },function(){
	$(this).removeClass('hovered');
    })
    
    
    //Hover States for Purchase Form
    $('#purchase_form ul li').hover(function(){
	$(this).addClass('hover');
    },function(){
	$(this).removeClass('hover');
    });
    
    //Overlay
    
    $('#sample_entry a').click(function(event){
	event.stopPropagation();
    });
    
    $("a[rel]").overlay({
	
	mask: 'darkred',
	
	onBeforeLoad: function() {
	    //// grab wrapper element inside content
	    //var wrap = this.getOverlay().find(".overlay_content");
	    
	    //// load the page specified in the trigger
	    //wrap.load(this.getTrigger().attr("href"));
	    
	    var wrap = this.getOverlay().find(".contentWrap");
	    var el = this.getTrigger().attr("href");
	    
	    // load the page specified in the trigger
	    wrap.load( siteUrl + "/st/" + el + '.html', function(){});	
	}
	
    });
    
    $('div[rel]').overlay({
	onBeforeLoad: function(){
	    var wrap = this.getOverlay().find(".contentWrap");
	    var el = this.getTrigger().attr("id");
	    // load the page specified in the trigger
	    wrap.load( siteUrl + "/elements/sample-entry-descriptions/" + el + '.html', function(){});	
	}
    });
});

