$(function(){
	
	$.initLinks(['nav a', '.inner-wrapper a', '.lightbox-wrapper a', '.subpage-inner-wrapper a', '.sidebar .menu a']);
		   
//	if($.browser.msie){ $.initIE(); };												//all IE related fixes
//	
//	if($.browser.msie && $.browser.version.substr(0, 1) < 7){ $.initIE6(); };		//all IE6 related fixes
		   
	$.populateCurrentYear(['span.current-year']);									//populate an element with current year, selectors passed as parameters
	
//	if($.colorbox){ $.initColorbox() };												//initiate all lightboxes 

//	var imgDir = 'images/';															//preload images
//	$.preloadImages(
//		imgDir + 'filename.gif',
//		imgDir + 'filename.gif'
//	);			   

	$.initNewWindowLinks(['.new-win']);												//initiate all new window links, selectors passed as parameters
	
	$('.menu-item-109').hover(function(){											//nav sub-menu slide
		$(this).children('.sub-menu').slideDown();
	}, function(){
		$(this).children('.sub-menu').slideUp();	
	
	});
	
	
		   
});//domready		   







/*****************************************************************************************************************************/
/* functions */
/*****************************************************************************************************************************/

$.initLinks = function(param){
	var speed = 300;												//holds how fast the animate happens
	$.each(param, function(i, v){									//loop through each parameter, i = array index, v = value

		var regColor = '#4e6cae';
		var hoverColor = '#68536F';


		if(v == 'nav a'){												//if the parameter is the main nav
			
			$(v).hover(function(){										//all main nav hover states

				var classes = $(this).parent('li').attr('class');		//get the links parent li class names
				if(classes.indexOf('current-menu-item') > 0 || classes.indexOf('current-page-ancestor') > 0){ 			//we're on the current page
					regColor = '#68536F';
					hoverColor = '#68536F';
				}else{													//we're not on the current page
					regColor = '#ffffff';
					hoverColor = '#68536F';				
				}	

				$(this)													
						.css({ 'color':regColor })						//set the css so that the stylesheet default doesn't happen the first time
						.animate({ 'color':hoverColor }, speed);		//animate to the new styles
					},function(){										//mouse out
						$(this).animate({ 'color':regColor }, speed);	//animate to the original styles
				
			});//hover
			
			
		}else if(v == '.sidebar .menu a'){	
			
			$(v).hover(function(){										//all side bar nav hover states
			
				var classes = $(this).parent('li').attr('class');		//get the links parent li class names
				if(classes.indexOf('current-menu-item') > 0){ 			//we're on the current page
					regColor = '#68536F';
					hoverColor = '#68536F';
				}else{													//we're not on the current page
					regColor = '#4e6cae';
					hoverColor = '#68536F';				
				}	

				$(this)													
						.css({ 'color':regColor })						//set the css so that the stylesheet default doesn't happen the first time
						.animate({ 'color':hoverColor }, speed);		//animate to the new styles
					},function(){										//mouse out
						$(this).animate({ 'color':regColor }, speed);	//animate to the original styles				
				
			});//hover			
					
			
		}else{															//all other pages

			$(v).hover(function(){										//category button mouseovers
		
				  $(this)													
					  .css({ 'color':regColor })						//set the css so that the stylesheet default doesn't happen the first time
					  .animate({ 'color':hoverColor }, speed);			//animate to the new styles
				  },function(){											//mouse out
					  $(this).animate({ 'color':regColor }, speed);		//animate to the original styles
				
			});//hover	
		
		}//if
		
	});//each	
};//initLinks


$.initColorbox = function(){

	$('a[rel="lightbox"]').colorbox({
		open:true, 
		'href':'?page_id=373',
		'innerWidth':'638px',
		'innerHeight':'490px',
		'width':'653px'
	})
	
};//initColorbox


//$.initIE = function(){
//	$('form ul li:last-child').css({ 'margin-bottom':'0' });
//	
//};//initIE
//
//
//$.initIE6 = function(){
//	DD_belatedPNG.fix('a, ul, div');																				//png fix
//	$('form input:text').addClass('txt');																				//add class name to text fields
//	$('form input:checkbox').addClass('chk');																			//add class name to checkboxes
//	$('form button:submit').addClass('btn-submit');
//};//initIE6
//
//
//var preLoadCache = [];
//// Arguments are image paths relative to the current page.
//$.preloadImages = function(){												//this function will pre-cache image files
//	var args_len = arguments.length;
//	for (var i = args_len; i--;){
//		var cacheImage = document.createElement('img');
//		cacheImage.src = arguments[i];
//		preLoadCache.push(cacheImage);
//	}
//};//preloadImages


$.populateCurrentYear = function(param){									//this function will populate an element with the current year
	$.each(param, function(i, v){											//loop through each parameter, i = array index, v = value
		$(v).text((new Date).getFullYear());								//set the current year	
	});//each
}//populateCurrentYear


$.initNewWindowLinks = function(param){										//this function will open links in a new window/browser tab
	$.each(param, function(i, v){											//loop through each parameter, i = array index, v = value
		$(v).click(function(){												//add click event
			$(this).attr({ 'target' : '_blank' });							//add the target="_blank" attribute
		});
	});//each
}//initNewWindowLinks

