
/* =Cookie */
	jQuery.cookie=function(a,b,c){
		if(typeof b!='undefined'){c=c||{};if(b===null){b='';c.expires=-1}var d='';if(c.expires&&(typeof c.expires=='number'||c.expires.toUTCString)){var e;if(typeof c.expires=='number'){e=new Date();e.setTime(e.getTime()+(c.expires*24*60*60*1000))}else{e=c.expires}d='; expires='+e.toUTCString()}var f=c.path?'; path='+(c.path):'';var g=c.domain?'; domain='+(c.domain):'';var h=c.secure?'; secure':'';document.cookie=[a,'=',encodeURIComponent(b),d,f,g,h].join('')}else{var j=null;if(document.cookie&&document.cookie!=''){var k=document.cookie.split(';');for(var i=0;i<k.length;i++){var l=jQuery.trim(k[i]);if(l.substring(0,a.length+1)==(a+'=')){j=decodeURIComponent(l.substring(a.length+1));break}}}return j}
	};


/* 
	OCP - jQuery Site Enhancements
	February 2010
	Atomic Crayon / karen@atomiccrayon.com / SMRT
*/



jQuery(document).ready(function(){
		
	
	/* =BODY CLASSES
	----------------------------------------------------*/
			
	// add class to body tag to indicate JS is on
	
	jQuery('html').addClass('jquery');
	
	// ie6, we still love you
	
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) {
			jQuery('html').addClass('ie6');
		}
	}
	
	
	
	/* =LINKS
	----------------------------------------------------*/
	
	// open rel="external" links in new windows
	
	jQuery("a[rel~='external']").click(function(){
		window.open(jQuery(this).attr('href'));
		return false;
	});
	
	/* =SEARCH
	----------------------------------------------------*/
	
	var default_value = 'search';
	
	var searchField = jQuery('#search #s');
	
	if (searchField.val() == '') {
		searchField.val(default_value);
	}
	
	searchField.focus(function() {
        if (searchField.val() == default_value) {
		  searchField.removeClass('blur');
            searchField.val('');
        }
    });
    searchField.blur(function() {
        if (searchField.val() == '') {
 		  searchField.addClass('blur');
           searchField.val(default_value);
        }
    });

	
	/* =NAVIGATION
	----------------------------------------------------*/
	
	// add sfhover class for dropdowns
	
	jQuery('#main-navigation li').hover(function() {
			jQuery(this).addClass('sfhover');
		}, function() {
			jQuery(this).removeClass('sfhover');
	});
	
	jQuery('#main-navigation ul li ul li.haschildren').hover(function() {
			jQuery(this).addClass('sfhover-parent');
		}, function() {
			jQuery(this).removeClass('sfhover-parent');
	});

	/*
	jQuery('.section-project #main-navigation .page-item-15').addClass('current_page_ancestor');


	jQuery('.section-media #main-navigation .page-item-53').addClass('current_page_ancestor');
	
	*/

	/* =META NAVIGATION
	----------------------------------------------------*/
	
	jQuery('#meta-navigation li').append('<span class="separator"> | </span>');
	jQuery('#meta-navigation li:last .separator').remove();


	/* =HOME
	----------------------------------------------------*/
	
	if (jQuery('body').hasClass("home")) {
	
	
	jQuery('.home #content #video li:eq(0)').addClass('headline');
	jQuery('.home #content #video li:eq(1)').addClass('title');
	jQuery('.home #content #video li:eq(2)').addClass('date');
	jQuery('.home #content #video li:eq(3)').addClass('description');
	jQuery('.home #content #video li:eq(4)').addClass('video');
	jQuery('.home #content #video li:eq(5)').addClass('view-more');
	
	
	// height of columns
	
	var One = parseInt(jQuery(".home #sidebar-2 .widget:eq(0)").height());
	var Two = parseInt(jQuery(".home #sidebar-2 .widget:eq(1)").height());
	var Three = parseInt(jQuery(".home #sidebar-2 .widget:eq(2)").height());
	var Four = parseInt(jQuery(".home #sidebar-2 .widget:eq(3)").height());

	var Tallest = Math.max(Math.max(One,Two), Math.max(Three,Four));
	
	//alert(Three);
	
	Tallest = Tallest + 'px';
	
	
	jQuery(".home #sidebar-2 .widget").height(Tallest);

	// cycle header images
	
	jQuery('.home #header').append('<div id="slideshow" class="slideshow"><img src="/wp-content/themes/ocp/images/photo-banner-home-1.jpg" width="940" height="253" /><img src="/wp-content/themes/ocp/images/photo-banner-home-2.jpg" width="940" height="253" /><img src="/wp-content/themes/ocp/images/photo-banner-home-3.jpg" width="940" height="253" /><img src="/wp-content/themes/ocp/images/photo-banner-home-4.jpg" width="940" height="253" /><img src="/wp-content/themes/ocp/images/photo-banner-home-5.jpg" width="940" height="253" /></div>');
	
	
	
	jQuery('.slideshow').cycle({
		fx: 'fade'
	});
	
	}

		
	/* =BODY CLASSES
	----------------------------------------------------*/

	
	/* =SITE MAP
	----------------------------------------------------*/
	jQuery('#content .ddsg-wrapper h2').hide();
	jQuery('#content .ddsg-wrapper p').hide();
	
	/* =FONT RESIZE
	----------------------------------------------------*/
	
	
	// add code
	
	jQuery('#font-size').after('<p id="text-size"> <!-- open TEXT-SIZE -->				<strong>Text</strong> <a href="#" class="size smaller" title="Decrease Font Size">A-</a> <a href="#" class="size larger" title="Increase Font Size">A+</a></p> <!-- close TEXT-SIZE -->');
	
	
	var CookieName = 'textSize';
	
	// Font Size
	var fontSize;
	var textBase = 76;
	var increment = 10;
	
	// Check for cookie
	
	var cookieSize = jQuery.cookie(CookieName);
	
	if (cookieSize > 0) {
		fontSize = Number(cookieSize);
		jQuery('body').css('font-size', fontSize + '%');
	}
	else {
		fontSize = textBase;
		jQuery('body').css('font-size', fontSize + '%');
	}
	
	// Check for clicks
	
	jQuery('.smaller').click(function(){
		fontSize = fontSize - increment;
		jQuery('body').css('font-size', fontSize + '%');
		jQuery.cookie(CookieName, fontSize, { path: '/', expires: 365 });
		return false;
	});
	
	jQuery('.larger').click(function(){
		fontSize = fontSize + increment;
		jQuery('body').css('font-size', fontSize + '%');
		jQuery.cookie(CookieName, fontSize, { path: '/', expires: 365 });
		return false;
	});
	

	/* =HEIGHTS
	----------------------------------------------------*/


	if (jQuery('body.error404').length == 0) {
	
		var mainHeight = jQuery('#main').height();
		jQuery('#sidebar').height(mainHeight - 20);
		jQuery('#section-navigation').height(mainHeight);
	
	}

});


