jQuery(document).ready(function(){
	

	jQuery.browser.msie = (navigator.appName == "Microsoft Internet Explorer");
	jQuery.browser.ie8 = (jQuery.browser.msie && parseInt(jQuery.browser.version) == 8);
	jQuery.browser.ie7 = (jQuery.browser.msie && parseInt(jQuery.browser.version) == 7);
	jQuery.browser.ie6 = (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7);

	jQuery('p span[style*="background-color"]').css('padding','1px 3px');

	if(jQuery('#pagetabs').size()){
		jQuery('#content > .post > h3:first-child').remove();
	}

	if(jQuery('body.blog,body.single-post').size()){
		jQuery('li.page_item.page-item-7499').addClass('current_page_item');
		jQuery('li.page-item-2').addClass('current_page_ancestor');
	}

	
	if(jQuery('#home').size()){
		var flashvars = { };
		var params = { allowScriptAccess: "always", wmode: "transparent" };
		var atts = { };
		swfobject.embedSWF("/wp-content/uploads/2010/05/mop_home_slider0505.swf", "flash", "710", "280", "10", null, flashvars, params, atts);
		
		if(!jQuery.browser.ie6)
		{
			jQuery('#home #intro #news_summary div.scroll').jScrollPane({
			 	scrollbarWidth: 10,
			 	scrollbarMargin: 10
			});
		}
		
	}

	// menu highlighting for tab pages
	if(jQuery('#pagetabs').size()) {
		jQuery('.nav_widget li.current_page_parent').addClass('active');
	}

	// HESHAN / START
	jQuery('#slider-two').movingBoxes({
	    startPanel  : 1,   // start with this panel
	    width       : 600, // overall width of movingBoxes
	    panelWidth  : .7,  // current panel width adjusted to 50% of overall width
	    imageRatio  : 4/3, // Image ratio set to 16:9
	    fixedHeight : false // if true, slider height set to max panel height; if false, slider height will auto adjust.
	});

	// Set up navigation links
	var i, t = '', len = $('#slider-one .panel').length + 1;
	for ( i=1; i<len; i++ ) {
	  t += '<a href="#" rel="' + i + '">' + i + '</a> ';
	}

	jQuery('.dlinks')
		.find('span').html(t).end()
		.find('a').click(function(){
			$('#slider-one').data('movingBoxes').currentPanel( $(this).attr('rel') );
			return false;
	});
	// HESHAN / END   

	// =======================================================================
	// = IE Shenanigans                                                      =
	// =======================================================================
	
	// get certain elements ready for alternate IE styling	
	if (jQuery.browser.ie6 || jQuery.browser.ie7 || jQuery.browser.ie8)
	{
		if (jQuery.browser.ie6){ jQuery('body').addClass('ie6').addClass('ie'); }	
		if (jQuery.browser.ie7){ jQuery('body').addClass('ie7').addClass('ie'); }
		if (jQuery.browser.ie8){ jQuery('body').addClass('ie8').addClass('ie'); }

		jQuery('#contentimage').wrapInner('<div class="outer_rounded" />');

		/*
		jQuery('div.outer_rounded').attr('style', jQuery('#contentimage').attr('style'));
		jQuery('div.outer_rounded').attr('style', 'background:red');
 		jQuery('#contentimage').attr('style', 'background:red url("/wp-content/themes/MassOcean/images/outer_rounded.gif") bottom left no-repeat;');
		jQuery('#contentimage').attr('style', 'border:none; background:transparent url("/wp-content/themes/MassOcean/images/outer_rounded.gif") bottom left no-repeat;');
		*/

		jQuery('#nav > ul > li:last-child').addClass('last-child');

		// ul#pagetabs li a,
		jQuery('ul#pagetabs li a, .content_box > h2, .gray_content_box > h2, li.widget > h2, .content_box > div, .gray_content_box > div, li.widget > div').addClass('boxed_ie').wrapInner('<div class="wrap1"><div class="wrap2"></div></div>');
		
		// set hover class for top li
		jQuery('#nav>ul>li').hover(
			function () { jQuery(this).addClass("hover"); },
			function () { jQuery(this).removeClass("hover"); }
		);

	}
	
	jQuery('.gallery a.facebox').facebox({footer:this.title});
	
	if(jQuery('.gallery a.facebox').length){ jQuery('body').addClass('nextgen-gallery'); }
	
	// use facebox modal popups
	jQuery('a.modal_popup').click(function(){
		var modal_target = this.href;
		jQuery.get(modal_target, function(data) {
			jQuery.facebox(data);
		});
		return false;
	});
	

	// if we're on the glossary page ... do this collapsing stuff.
	$('div.expandable').expander({
	  slicePoint: 50,
	  widow: 2,
	  expandEffect: 'show',
	  expandText:       '[read more]',
	  expandPrefix:     '',
	  userCollapseText: '[hide]'
	});
	
	jQuery('div.glossary').after('<a href="" class="glossary">[working definition]</a>');
	jQuery('a.glossary').click(function(){
		if(jQuery(this).html() == "[working definition]")
		{
			jQuery(this).prev().fadeIn();
			jQuery(this).html('[hide]');
		} else {
			jQuery(this).prev().fadeOut();
			jQuery(this).html('[working definition]');
		}
		return false
	});
	
});

