$(window).load(function(){
	if ($('img').hasClass('brd')) {	
		$('img.brd').each( function() {		
			var width = $(this).width()-16; //removing 16 pixels to account for border below in css
			var height = $(this).height()-16; //removing 16 pixels to account for border below in css
			$(this).wrap('<div style="position:relative;"></div>');
			$(this).before('<div style="width:'+width+'px; height:'+height+'px; position:absolute; border:solid 8px #ccc; display:block; filter:alpha(opacity=40); -moz-opacity: 0.4; opacity: 0.4;"></div>');			
	})	
	}	
	
});


$(document).ready(function(){

$("#csFrom_ID, #csTo_ID").datepicker();


$("#year").text( (new Date).getFullYear() );

// -------------------------------------------------------------------------------------------
// Small Calendar Dots
// -------------------------------------------------------------------------------------------
//$('#SmallCal td.Business-Development-and-Client-Relations').append('<div class="SQ1"> </div>');
//	$('.SQ1').css({ background: '#003359', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });
//$('#SmallCal td.Firm-Management-and-Leadership').append('<div class="SQ2"> </div>');
//	$('.SQ2').css({ background: '#739abc', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });
//$('#SmallCal td.Legal-Expertise').append('<div class="SQ3"> </div>');
//	$('.SQ3').css({ background: '#cd7a31', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });
//$('#SmallCal td.Practice-Skills').append('<div class="SQ4"> </div>');
//	$('.SQ4').css({ background: '#ca9b4a', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });
//$('#SmallCal td.Professional-Responsibility').append('<div class="SQ5"> </div>');
//	$('.SQ5').css({ background: '#898f4b', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });
//$('#SmallCal td.Talent-Management').append('<div class="SQ6"> </div>');
//	$('.SQ6').css({ background: '#8683a4', width: '7px', height: '7px', padding: '1px', margin: '1px', display: 'inline-block', overflow: 'hidden' });

// -------------------------------------------------------------------------------------------
// Superfish dropdown menus
// -------------------------------------------------------------------------------------------

$('ul.sf-menu').supersubs({ 
	minWidth:    12,   // minimum width of sub-menus in em units 
	maxWidth:    27,   // maximum width of sub-menus in em units 
	extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
					   // due to slight rounding differences and font-family 
}).superfish({ 
	hoverClass:   'sfHover',          			  // the class applied to hovered list items 
	pathClass:    'TNCurrent', 			  		  // the class you have applied to list items that lead to the current page 
	pathLevels:   1,                  			  // the number of levels of submenus that remain open or are restored using pathClass 
	delay:        200,               			  // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
	animation:    {opacity:'show',height:'show'},  // fade-in and slide-down animation 
	speed:        'fast',                          // faster animation speed 
	autoArrows:   true,                            // disable generation of arrow mark-up 
	dropShadows:  true                             // disable drop shadows 
}); 

$("ul.sf-menu").lavaLamp({
	fx: "easeOutBack", 
	speed: 400
});


// -------------------------------------------------------------------------------------------
// Scroll to top
// -------------------------------------------------------------------------------------------

var blue_css = { background: '#E5F6FE',	color: '#4D9FBF', border: '2px solid #ADD9ED' }
var green_css = { background: '#CDE6AC', color: '#58792E', border: '2px solid #A9DB66' }
var red_css = { background: '#f28279', color: '#9C2F2F', border: '2px solid #CE6F6F' }
var dark_css = { background: '#404040',	color: '#f3f3f3', border: '2px solid #303030' }
var light_css = { background: '#f1f1f1', color: '#454545', border: '2px solid #E2E2E2' }
var cream_css = { background: '#F0DE7D', color: '#A27D35', border: '2px solid #F9E98E' } 
var taup_css = { background: '#E8E6E3', color: '#928b81', border: '2px solid #D7D3D0' }
		
/*---Creates the scroll to top link---*/
$('body').prepend('<a href="javascript:;" id="toTop">^ Scroll to Top</a>');
	$('#toTop').css({ 
		width: '85px',
		'font-size': '9px',
		padding: '5px',
		position: 'fixed',
		bottom: '10px',
		right: '10px',
		cursor: 'pointer',
		'text-align': 'center',
		'text-decoration': 'none'
		//color: '#666',
		//background: '#f1f1f1',
		//border: '1px solid #ccc'
});
$('#toTop').css(dark_css)
			
/*---Starts the scroll to top function that uses the link above. This must come after the link is created above.---*/
$(function() {
	$("#toTop").scrollToTop({speed:800});
});

// -------------------------------------------------------------------------------------------
// Clear input field of values
// -------------------------------------------------------------------------------------------

$.fn.clearDefault = function(){  
	return this.each(function(){  
		var default_value = $(this).val();  
		$(this).focus(function(){  
			if ($(this).val() == default_value)  
						  $(this).val("");  
		});  
		$(this).blur(function(){  
			if ($(this).val() == "")  
						  $(this).val(default_value);  
		});  
	});  
};
$('searchfield').clearDefault(); 
	
// -------------------------------------------------------------------------------------------
// Adds a focus class to the parent element so you can see what field you are on
// -------------------------------------------------------------------------------------------
			
$(".content input").focus(function() {
	$(this).parent().addClass("curFocus")
});
	$(".content input").blur(function() {
	$(this).parent().removeClass("curFocus")
});
	
// -------------------------------------------------------------------------------------------
// Creates the fadin and out on all links
// -------------------------------------------------------------------------------------------

//$("#tabs-nav li, a img, .SideNav a").hover(function(){
//		$(this).fadeTo(350, 0.5); // This should set the opacity to 100% on hover
//	},function(){
//		$(this).fadeTo(450, 1.0); // This should set the opacity back to 60% on mouseout	
//});				

// -------------------------------------------------------------------------------------------
// Adds the icons after links and makes external links open in new window
// -------------------------------------------------------------------------------------------

var fileTypes = {
  doc: 'doc.gif',
  xls: 'xls.gif',
  pdf: 'pdf.gif'
};
 
$('#content a').each(function() {
 
  var $a = $(this);
  var href = $a.attr('href');
  
  if (!$a.children('img').size()) { 
	  if ((this.href.match(/^http\:/i)) && (!this.href.match(document.domain))) {				 
		// use a special image for external links
		var image = 'extlink.gif';
		//makes external links open in new window
		$a.attr("target", "_blank"); 
	  } 				  
	  else {					  
			if (this.href.match(/^mailto\:/i)) {				 
			// use a special image for mailto links
			var image = 'mailto.gif';					
			}
			else {
			// get the extension from the href
			var hrefArray = this.href.split('.');
			var extension = hrefArray[hrefArray.length - 1];
			var image = fileTypes[extension];
		  }
	  }
	   if (image) {
		$a.after('<img src="/images/lmln/Template/css/images/'+image+'" alt="Link Icon" align="absmiddle" style="margin:2px 3px 0px 4px;">');
	  }
	}
});	

// -------------------------------------------------------------------------------------------
// Makes links to the following file types open in new windows
// -------------------------------------------------------------------------------------------

$("a[href*=.pdf]").attr("target", "_blank");
$("a[href*=.doc]").attr("target", "_blank");  
$("a[href*=.xls]").attr("target", "_blank");  
$("a[href*=.ppt]").attr("target", "_blank"); 
$("a[href*=.pps]").attr("target", "_blank"); 

// -------------------------------------------------------------------------------------------
// Creates the alternating table rows and hover
// -------------------------------------------------------------------------------------------
		
//This will make table rows and columns change color on hover.
//CSS needed = .hover { background-color: #eee; }
$(".NCCCourseListTable").delegate('td','mouseover mouseleave', function(e) {
	if (e.type == 'mouseover') {
	  $(this).parent().addClass("hover");
	  $("colgroup").eq($(this).index()).addClass("hover");
	}
	else {
	  $(this).parent().removeClass("hover");
	  $("colgroup").eq($(this).index()).removeClass("hover");
	}
});		
$(".NCCCourseListTable tr:even").css({ backgroundColor: "#fff" });
//Adds the hover and fade in out effect.
jQuery.fn.confirmFlash = function(config){ 
			this.each(function() { 
					var elem = jQuery(this); 
	 
					// Store the starting background color 
					var startBg = elem.css("backgroundColor"); 
	 
					// When the element is clicked 
					elem.hover(function() { 
							// Set the start background color 
							elem.css("backgroundColor", startBg);
							// Animate to the "flash" color 
							elem.stop().animate({ backgroundColor: config.backgroundColor}, 600);  
							},function() {  
							elem.stop().animate({ backgroundColor: startBg }, 400);										
					}); 
			}); 
	}; 
$(".NCCCourseListTable tr").confirmFlash({backgroundColor: "#ECECF0"}); 

// -------------------------------------------------------------------------------------------
// Tabs 
// -------------------------------------------------------------------------------------------

$(".tabs h2").each(function() {
	$(this).nextUntil("h2").wrapAll('<div class="tabbody" />');
	});
$(".tabs").accessibleTabs({
	tabhead: 'h2',
	fx:"fadeIn",
	tabbody:'.tabbody'
});	


// -------------------------------------------------------------------------------------------
// Looped Slider 
// -------------------------------------------------------------------------------------------

$('#loopedSlider').loopedSlider({ 
	container: ".lS-container", //Class/id of main container. You can use "#container" for an id.
	slides: ".slides", //Class/id of slide container. You can use "#slides" for an id.
	pagination: "pagination", //Class name of parent ul for numbered links. Don't add a "." here.
	containerClick: false, //Click slider to goto next slide? true/false
	items: 1, // Items shown
	autoStart: 10000, //Set to positive number for true. This number will be the time between transitions.
	restart: 9000, //Set to positive number for true. Sets time until autoStart is restarted.
	slidespeed: 300, //Speed of slide animation, 1000 = 1second.
	fadespeed: 300, //Speed of fade animation, 1000 = 1second.
	autoHeight: 1500, //Set to positive number for true. This number will be the speed of the animation.
	addPagination: true //Add pagination links based on content? true/false
	//padding: 10, // Padding between items
});
$('#loopedSlider .slides div').css('backgroundColor', '#fff'); 

	
});

// -------------------------------------------------------------------------------------------
// Font sizer. This must be loaded before the tooltip for tooltips to work
// -------------------------------------------------------------------------------------------

$("#fontsizer").fontScaler({
	target: '#content',
		containerclass: 'fontScaler',
		store:true,
		fx: 'smooth',
		fxspeed: '100',
		fixed: {
			size1: '100',
			size2: '120',
			size3: '145'
		}
});	
		
// -------------------------------------------------------------------------------------------
// Tooltip plugin. Only loaded if it finds a title tag.
// -------------------------------------------------------------------------------------------
	
$(function() {
  $("#footer [title], #header [title]").tipsy({
		delayIn: 0,      // delay before showing tooltip (ms)
		delayOut: 0,     // delay before hiding tooltip (ms)
		fade: true,     // fade tooltips in/out?
		fallback: '',    // fallback text to use when no tooltip text
		gravity: $.fn.tipsy.autoNS,    // gravity nw | n | ne | w | e | sw | s | se
		html: false,     // is tooltip content HTML?
		live: false,     // use live event support?
		offset: 0,       // pixel offset of tooltip from element
		opacity: 0.5,    // opacity of tooltip
		title: 'title',  // attribute/callback containing tooltip text
		trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	});   
});



