$(document).ready(function(){

	$(".icon_link").fadeTo("fast", 1.0);

		$(".icon_link").hover(function(){
			$(this).fadeTo("fast", 0.8);
		},function(){
			$(this).fadeTo("fast", 1.0);
		});

	$(".client_logo").fadeTo("fast", 0.7);

		$(".client_logo").hover(function(){
			$(this).fadeTo("slow", 1.0);
		},function(){
			$(this).fadeTo("slow", 0.7);
		});

	$(".course_menu").fadeTo("fast", 0.6);

		$(".course_menu").hover(function(){
			$(this).fadeTo("fast", 1.0);
		},function(){
			$(this).fadeTo("fast", 0.6);
		});

		pinballEffect();
		adjustColumns();
		externalLinks();

	$(".polaroid").hover(
		function () {

			this.style.cursor = "pointer";
			this.style.cursor = "hand";
			var tmp = this.id.split('_');
			var el = '#'+'polaroidQuote_'+tmp[1];
				$(el).show("fast");
		},
		function () {
			var tmp = this.id.split('_');
			var el = '#'+'polaroidQuote_'+tmp[1];
				$(el).hide("fast");
		}
	);

	$(".polaroid").click(
		function () {
			var tmp = this.id.split('_');
			var url = "/stories.php?id="+tmp[1]+"&KeepThis=true&TB_iframe=true&height=400&width=700";
// 			var url = 'http://google.com';
			tb_show("Success Story", url, "");
		}
	);




	$(".polaroid2").hover(
		function () {

			this.style.cursor = "pointer";
			this.style.cursor = "hand";
			var tmp = this.id.split('_');
			var el = '#'+'polaroidQuote_'+tmp[1];
				$(el).show("fast");
		},
		function () {
			var tmp = this.id.split('_');
			var el = '#'+'polaroidQuote_'+tmp[1];
				$(el).hide("fast");
		}
	);

	$(".polaroid2").click(
		function () {
			var tmp = this.id.split('_');
			var url = "/team.php?id="+tmp[1]+"&KeepThis=true&TB_iframe=true&height=400&width=700";
// 			var url = 'http://google.com';
			tb_show("Our Team", url, "");
		}
	);


	$(".ploaroid").equalHeights();


});

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 112,top = 84');");
}

function adjustColumns() {
	if(document.getElementById('contentSide')) {
		var mainC = document.getElementById('contentMain');
		var sideC = document.getElementById('contentSide');
	
		if(sideC.offsetHeight < mainC.offsetHeight)
			sideC.style.height = (mainC.offsetHeight+200)+"px";

	}
}

/*
	pinballEffect()
	written by Adam Khan.
	http://www.digital-web.com/articles/the_pinball_effect/
*/
var W3CDOM = (document.createElement && document.getElementsByTagName);
function pinballEffect()
{
	if (!W3CDOM) return;
	var allElements = document.getElementsByTagName('*');
	var originalBackgrounds=new Array();
	for (var i=0; i<allElements.length; i++)
	{
		if (allElements[i].className.indexOf('pinball-scoop') !=-1)
		{
			allElements[i].onmouseover = mouseGoesOver;
			allElements[i].onmouseout = mouseGoesOut;
			allElements[i].onclick = mouseGoesClick;
		}
	}
}



function mouseGoesOver()
{

	originalClassNameString = this.className;
	this.className += " pinball-on";
	this.style.cursor = "pointer";
	this.style.cursor = "hand";




}

function mouseGoesOut()
{
	this.className = originalClassNameString;
}

function mouseGoesClick()
{
	var allThisAreasElements = this.getElementsByTagName('*');
	for (var j=0; j<allThisAreasElements.length; j++)
	{
		if (allThisAreasElements[j].className.indexOf('pinball-sinkhole') != -1)
		{
			var url = allThisAreasElements[j].href;
			window.location = url;
		}
	}
}


function externalLinks() {

	var theLinks = document.links;

	if (!document.links)
		{
		document.links = document.getElementsByTagName('a');
		}


	var thisDomain = window.location.hostname;


	for (i=0; i < theLinks.length; i++) {
		var thisLink = theLinks[i];
		  if (thisLink.href.indexOf(thisDomain) == -1 && thisLink.href.indexOf("javascript") == -1) {
    			thisLink.target = "_blank";
   			}
  	}
}




/*-------------------------------------------------------------------- 
 * 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


 * 29 May 09	- EDITED to work without dependencies & doesn't bother with children just the class passed to the fn
				- eoin@starfish.ie
--------------------------------------------------------------------*/

$.fn.equalHeights = function() {
	var currentTallest = 0;
	$(this).each(function(){

			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
	});

	$(this).each(function(){

		$(this).css({'height': currentTallest}); 

	});

	return this;
};


