/*--------------------------------------------------------------------------*
 *  
 *  imageReplace JavaScript Library beta3
 *  
 *  
 *  
 *--------------------------------------------------------------------------*/

new function(){
	
	var ImagesDir = "./";
	
	if(window.addEventListener){
		window.addEventListener('load',imageReplace,false);
	}else if(window.attachEvent){
		window.attachEvent('onload',imageReplace);
	}
	
	function imageReplace(){

		elements = document.getElementsByClassName("imageReplace");

		for (var i=0; i<elements.length; i++) {

			var element = elements[i];

			var classnames = element.getAttribute('className') || element.getAttribute('class');
			var classes = classnames.split(" ");
			if(classes[2]){
				var onImg  = " onmouseover=\"this.src='"+ImagesDir+classes[2]+"'\"";
				var offImg = " onmouseout=\"this.src='"+ImagesDir+classes[1]+"'\"";
			}else{
				var onImg  = "";
				var offImg = "";
			}
			if(classes[1])element.innerHTML = '<img src="'+ImagesDir+classes[1]+'" alt="'+element.innerHTML+'" id="imageReplace'+i+'" border="0" '+onImg+offImg+'/>';
		}
	}
	
	document.getElementsByClassName = function(className){
		var i, j, eltClass;
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		var objCN = new Array();
		for (i = 0; i < objAll.length; i++) {
			eltClass = objAll[i].className.split(/\s+/);
			for (j = 0; j < eltClass.length; j++) {
				if (eltClass[j] == className) {
					objCN.push(objAll[i]);
					break;
				}
			}
		}
		return objCN;
	}
}


/*-------------------------------------------------------------------- 
 * JQuery Plugin: "EqualHeights"
 * by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
 *
 * Copyright (c) 2008 Filament Group
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Description: Compares the heights or widths of the top-level children of a provided element 
 		and sets their min-height to the tallest height (or width to widest width). Sets in em units 
 		by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method	(article: 
		http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)							  
 * Usage Example: $(element).equalHeights();
  		Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
 * Version: 2.0, 08.01.2008
--------------------------------------------------------------------*/

$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};
