﻿// ha.js
// Dynamic Behaviors for hennemanarchitects.com.
// Written by Will Fastie, March 2010

/*global JHA */
JHA = {};

/* Functions for the site */
JHA.preload_images = function () {
	if (document.images) {
		var menu_img_1 = new Image(); menu_img_1.src = "/img/menu/btn-about_hov.gif";
		var menu_img_2 = new Image(); menu_img_2.src = "/img/menu/btn-contact_hov.gif";
		var menu_img_3 = new Image(); menu_img_3.src = "/img/menu/btn-home_hov.gif";
		var menu_img_4 = new Image(); menu_img_4.src = "/img/menu/btn-projects_hov.gif";
	}
};

/* Immediate Code - Executes on load */

/* Establish hover behavior where needed - class="hovereffect" */
$(document).ready(function(){
	$("img.hovereffect, input.hovereffect").hover(
	  function() {
	    this.src = this.src.replace( /_std\.png$/, '_hov.png' );
	    this.src = this.src.replace( /_std\.gif$/, '_hov.gif' );
	    this.src = this.src.replace( /_std\.jpg$/, '_hov.jpg' );
	  },
	  function() {
	    this.src = this.src.replace( /_hov\.png$/, '_std.png' );
	    this.src = this.src.replace( /_hov\.gif$/, '_std.gif' );
	    this.src = this.src.replace( /_hov\.jpg$/, '_std.jpg' );
	  }
	);
  // Establish hover behavior img tags inside a tags
	$("a.hovereffect").hover(
	  function() {
		  var i = $(this).find('img');
	    i.attr('src', i.attr('src').replace( /_std\.gif$/, '_hov.gif' ));
	    i.attr('src', i.attr('src').replace( /_std\.png$/, '_hov.png' ));
	    i.attr('src', i.attr('src').replace( /_std\.jpg$/, '_hov.hpg' ));
	  },
	  function() {
		  var i = $(this).find('img');
	    i.attr('src', i.attr('src').replace( /_hov\.gif$/, '_std.gif' ));
	    i.attr('src', i.attr('src').replace( /_hov\.png$/, '_std.png' ));
	    i.attr('src', i.attr('src').replace( /_hov\.jpg$/, '_std.jpg' ));
	  }
	);
	// Establish hover behavior for project and job page avatars
  $('.p-link').hover(
  	function() {
  		$('img', this).css('border', '2px solid #6666CC');
  		$('a', this).css('color', 'aqua');
  	},
  	function() {
  		$('img', this).css('border', '2px solid black');
  		$('a', this).css('color', 'white');
  	}
  );
	// Establish hover behavior for the main photo image on the project page
/*   $('.project-main-image').hover(
  	function() {
  		$('img', this).css('border', '2px solid #6666CC');
  		$('a', this).css('color', 'aqua');
  	},
  	function() {
  		$('img', this).css('border', '2px solid black');
  		$('a', this).css('color', 'white');
  	}
  );
 */});

