 $(document).ready(function(){ 
	$('body').addClass('hasJS');
}); 
function replaceFont() {
	//Important: a class=replacefont is highly recommended to add , in all the html tags where a font replacement will be applied as bellow:
	//http://wiki.github.com/sorccu/cufon/api
	Cufon.replace('.replacefont', { fontFamily: 'Berthold Imago' });
	Cufon.replace('.replacefontlight', { fontFamily: 'Berthold Imago BQ' });
}
//Call replaceFont():  
replaceFont();

/**
 * normalizeSiblingsHeightsByRow - Sets equal heights on all elements in each row, in a collection of HTML elements.
 * @selector = CSS selector of items to adjust
 * @rowcount = number of items per row
 * @clearance = amount of pixel to clear before going to 3 full rows (3 items per row) // Used for hot spots banners
 */
function normalizeSiblingsHeightsByRow(selector, rowcount, clearance) {
	var row,
		rows = [],
		rowCounter = 0,
		clearanceCounter = clearance,
		highestHeight = 0;
	$(selector).each(function() {
		if (rowCounter === 0) {
			row = [];
			rows.push(row);
			clearanceCounter = clearanceCounter - highestHeight;
			rowCounter = (clearanceCounter > 0) ? rowcount-1 : rowcount;
			highestHeight = 0;
		}

		highestHeight = ( $(this).outerHeight() > highestHeight ) ? $(this).outerHeight() : highestHeight;
		row.push(this);
		/*console.log(rowCounter, $(this).html());*/
		if(	rowCounter === 1 && clearanceCounter > 0 && clearance !== 0)
		{
			$(this).css("paddingRight","2px");
			/*$(this).css("border","1px");
			$(this).css("border-color","#0F0");
			$(this).css("border-style","solid");*/
		}
		rowCounter = rowCounter - 1;
		
	});
	
	$(rows).each(function() {
		normalizeSiblingsHeights(this);
	});
}
			
//Disabled because it was forcing all rows to the same height, not just cells from the same row.
function normalizeSiblingsHeights(elements) {
	// Sets same height (highest of all sibling elements) to all sibling elements
	var sortDescending = function(a,b) { return b - a; };
	var sortAscending = function(a,b) { return a - b; };
	var elementsHeights = new Array();
	// Finding highest of them all
	for(i=0;i<elements.length;i++) {
		elementsHeights[i] = elements[i].offsetHeight;
	}
	elementsHeights.sort(sortDescending);
	var highestElement=elementsHeights[0];
	
	// Set everyone the same height
	for(j=0;j<elements.length;j++) {
		
		elements[j].style.height = highestElement + "px";

	}
}
/*
*/

function toggleShowHide(el, params) {
	/* Use class "persist" on the LI you want to keep from hiding */
	elList = $(el).prev().children();
	if ($(elList).hasClass('show')) {
		$(elList).removeClass('show');
		$(elList).addClass('hide');
		$(el).text(params.moreString);
	}
	else {
		$(elList).removeClass('hide');
		$(elList).addClass('show');
		$(el).text(params.lessString);
	}
}

(function($){
 //LISTCOLUMNIZE V1.0
 //jQuery Plugin by Marc-André Arseneault
 //Email: marc-andre.arseneault@nurun.com
 $.fn.listColumnize = function(options) {
  var defaults = {
   approxHeight: 300,
   columns : 3,
   colWidth : "300px",
   listElm : $("ol"),
   container : $(this)
  },
  options = $.extend(defaults, options),
  init = function(){
	var columns = new Array();
	for(var i=0;i<options.columns;i++){
		var column = $("<div></div>").addClass("column").css({"float":"left","width":options.colWidth}),
			colHeight = 0,
			elm = $(options.container).find($(options.listElm)),
			len = elm.length;
		if(i==0) column.addClass("first");
		if(i==options.columns-1) column.addClass("last");
		if(i==0 && i==options.columns-1) column.removeClass("first last");
		$.each(elm,function(f,e){
			$(e).clone().appendTo(column);
			colHeight += $(e).outerHeight(true);
			$(e).remove();
			if(colHeight >= options.approxHeight) {
				columns.push(column);
				return false;
			}
			if(f==len-1){
				columns.push(column);
			}
		})
	}
	$.each(columns,function(i,e){
		$(e).appendTo(options.container);
	})
	$("<br>").css("clear","both").appendTo(options.container);
  }
  return init();
 };
})(jQuery);


