/* 
   Shore Consulting Group
   JavaScript
*/

$(document).ready(function() {
    // call the equalize function
    equalHeight($("#sec_who div.col_two"));
	equalHeight($("#sec_who div.col_three"));
    equalHeight($("#sec_what div.col_two"));
	equalHeight($("#sec_what div.first_row"));
	equalHeight($("#sec_what div.second_row"));
	equalHeight($("#sec_contact div.col_two_one, #sec_contact div.col_three"));
	
	// animate scrolling
    $("#nav_main a[href*=#], #nav_sub a[href*=#]").click(function(e) {
		e.preventDefault()
		var $target = $(this.hash);
		$("html,body").animate({
			scrollTop: $target.offset().top
		},{
			"easing": "easeOutExpo",
			"duration": 750
		});
		//$.scrollTo($target);	
		// change active link
		$("a").removeClass("active")
		$(this).addClass("active")
		//
		return false;
    });
	
	// init sliders
	$("#feature_slider").easySlider({
		auto: true,
		continuous: true,
		nextId: "nextFeatureSlide",
		prevId: "prevFeatureSlide",
		speed: 800
	});
	$("#cards_slider").easySlider({
		auto: false,
		continuous: true,
		nextId: "nextCardsSlide",
		prevId: "prevCardsSlide",
		speed: 900
	});
	$("#howwedoit_slider").easySlider({
		auto: false,
		continuous: true,
		numeric: true,
		speed: 400
	});
	// move howwedoit slider controls
	ctrls = $("#controls").detach();
	$("p.chart_how").append(ctrls);
	// show/hide card link
	$("a.show_link").click(function(e) {
		e.preventDefault()
		// open/close
		$(this).parent().next($("div.get_link")).toggle();
		// select link text
		var element = $(this).parent().next($("div.get_link")).children("p").attr("id");
		selectText($(this))
	})
	$("a.close_link").click(function(e) {
		e.preventDefault()
		// open/close
		$(this).parent().toggle();
	})
}); 


// equalize column heights function
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
// select text in element
function selectText(element){
	//var text = document.getElementById(element);
	var text = $(element).parent().next($("div.get_link")).children("p").text();
	if ($.browser.msie) {
		var range = document.body.createTextRange();
		range.moveToElementText(text);
		range.select();
	} else if ($.browser.mozilla || $.browser.opera) {
		var selection = window.getSelection();
		var range = document.createRange();
		range.selectNodeContents(text);
		selection.removeAllRanges();
		selection.addRange(range);
	} else if ($.browser.safari) {
		var selection = window.getSelection();
		selection.setBaseAndExtent(text, 0, text, 1);
	}
};
//
var findActiveSection = {
	
}







