// equal heights function
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
$(document).ready(function() {
	// add first-child and last-child classes to lists
	$("ul li:first-child").addClass('first-child');
	$("ul li:last-child").addClass('last-child');
	// initialize slider
	if ($('#slider')[0] ) {
		$("#slider").easySlider({
			auto: true,
			continuous: true,
			numeric: true,
			pause: 4500
		});
	}
	// faq accordion
	if ( $('.faqs')[0] ) { 
		$(".faqs").accordion({
			fillSpace: false,
			active: false,
			collapsible: true,
			autoHeight: false,
			navigation: 'enabled'
		});
	}
	// match heights
	$("div.boxes").matchHeights({
		minHeight: null, // optional minimum height setting
		maxHeight: null, // optional maximum height setting, forced height instead of min-height
		overflow: false // sets overflow to be hidden. Default is false; overflow attribute not set
 	});
	// set equal heights
	if ($('.ourprods')[0] ) {
		equalHeight($(".ourprods li ul"));
	}
	if ($('.boxes')[0] ) {
		equalHeight($(".boxes .body"));
	}
	if ($('#network li')[0] ) {
		equalHeight($("#network li"));
	}
	if ($('.bro')[0]) {
		if (!$('.methodscontact')[0]) {
			$("#cont").addClass("borrer");
		}
	}
	/* 
	if (windoww > (content + 26))
	{
		var header = $("#header").height();
		var neww = (windoww - header) - 26;
		$("#contenthouse").height(neww);
	} */
	// check if browser is NOT IE
	if (!($.browser.msie)) {
		// fade provider icons
		if ($('#providers ul')[0] ) {
			var def = 0.5;
			$("#providers ul li a").fadeTo("slow", def);
			$("#providers ul li a").hover(function(){
				$(this).fadeTo("fast", 1.0); // hover
			},function(){
				$(this).fadeTo("fast", def); // mouseout
			});
		}
		if ($('#share ul')[0] ) {
			var def = 0.5;
			$("#share ul li a").fadeTo("slow", def);
			$("#share ul li a").hover(function(){
				$(this).fadeTo("fast", 1.0); // hover
			},function(){
				$(this).fadeTo("fast", def); // mouseout
			});
		}
	}
	//
	// ALWAYS AT THE END!!! once window has loaded, do the following....
	$(window).load( function() {
		// window height, footer adjustment
		var windoww = document.documentElement.clientHeight;
		var header = $("#header").outerHeight(true);
		var wholer = $("#wholer").outerHeight(true);
		var footer = $("#footerhouse").outerHeight(true);
		var content = header + wholer + footer;
		if (windoww > content) {
			var neww = (windoww - header - footer);
			$("#wholer").height(neww);
		}
		else {
			// nothing.
		}
	});
});
