function showOverlay(link,fn, behavior, w, h){
	var behave = "";
	var check = true;
	var winWidth = 380;
	var winHeight = 500;
	var callback = null;
	if(behavior){
		behave = behaviour;
	}
	if(w) {
		winWidth = w; 
		check = false;
	}
	if (h) {
		winHeight = h;
		check = false;
	}
	if (fn) {
		callback = fn;
	}
	if (check) {
		if ($(link).hasClass('tall') || behave == 'tall') {
			winHeight = 400;
			winWidth = 400;
		} else if ($(link).hasClass('wide') || behave == 'wide') {
			winWidth = 750;
			winHeight = 400;
		} else if ($(link).hasClass('big') || behave == 'big') {
			winWidth = 750;
			winHeight = 500;
		} else if ($(link).hasClass('coupon') || behave == 'coupon') {
			winWidth = 435;
			winHeight = 225;
		} else if ($(link).hasClass('small') || behave == 'small') {
			winWidth = 400;
			winHeight = 75;
		} else if ($(link).hasClass('short') || behave == 'short') {
			winWidth = 400;
			winHeight = 300;
		} else if ($(link).hasClass('participation') || behave == 'participation') {
			winWidth = 780;
			winHeight = 600;
		} else if ($(link).hasClass('video') || behave == 'video') {
			winWidth = 480;
			winHeight = 385;
		}
		if(!fn){
			if ($(link).hasClass('print')){
				callback = printPage;
			}
		}
	}
	if(!jQuery.support.boxModel){winWidth = winWidth + 40;winHeight = winHeight - 40;} /*IE 6/7 padding*/
	$(link).fancybox({
		'hideOnContentClick': false,
		'frameWidth':winWidth,
		'frameHeight':winHeight,
		'padding':20,
		'overlayShow':false,
		'callbackOnShow': callback
	});
}

$(function(){
	
	/* Quiz toggle functionality */
	if($('a.i-toggle')){
		$('a.i-toggle').click(function(){
			var tar = this.href;
			if(tar.indexOf('#') < 0){ return true;}
			tar = tar.substring(tar.indexOf('#'));
			if($(tar).parents('.toggle').is('.toggle')){
				$(tar).parents('.toggle').find('.toggle').slideUp();
			}
			if($(tar).is(':visible')){
				$(tar).removeClass('i-down').slideUp();
			} else {
				$(tar).slideDown().addClass('i-down');
			}
			return false;
		});
		$('a.i-toggle-correct').hover(function(){
			$(this).css({'cursor':'pointer','text-decoration':'underline'});
		}, function() { var cssObj = { 'text-decoration':'none' } 
			$(this).css(cssObj); 
		});
		$('a.i-toggle-hide').hover(function(){
			$(this).css({'cursor':'pointer','text-decoration':'underline'});
		}, function() { var cssObj = { 'text-decoration':'none' } 
			$(this).css(cssObj); 
		});
		$('a.i-toggle-correct').click(function(){
			$(this).parent().parent().find('div.answer').slideUp().end().find('div.correct').slideDown();
		});
		$('a.i-toggle-hide').click(function(){
			$(this).parent().parent().find('div.answer').slideUp();
		});
	}
/*
$("p").hover(function () {
  $(this).css({'background-color' : 'yellow', 'font-weight' : 'bolder'});
}, function () {
  var cssObj = {
    'background-color' : '#ddd',
    'font-weight' : '',
    'color' : 'rgb(0,40,244)'
  }
  $(this).css(cssObj);
});
*/

});

$(document).ready( function() {
	$('div.section.bubbles > div, #promoBanners > div, #eeTiles > div').mouseenter(function() {
		$('.hoverText', this).slideDown('fast');
		return false;
	});
	$('div.section.bubbles > div, #promoBanners > div, #eeTiles > div').mouseleave(function() {
		$('.hoverText', this).slideUp('fast');
		return false;
	});
	$("a.infobox").each(function(i){
		if (this.href.indexOf('?') > -1) {
			this.href = this.href + '&mode=ajax';
		}
		else {
			this.href = this.href + '?mode=ajax';
		}
		showOverlay(this);
	});
});

