/* Reveals extra column when screen width is detected as being wide enough */

function hiddenExtras() 
{
	if ( ! $('#container').length ) 
	{
		return false;
	}

	if (self.innerHeight) // all except Explorer
	{
		ascWide = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		ascWide = document.documentElement.clientWidth;
	}
	else if (document.body) // other Explorers
	{
		ascWide = document.body.clientWidth;
	}

	if (ascWide > 1200) 
	{
		$('#container').width(1220);
		$('#container').css('marginLeft',0);
		$('#container').css('margin-right',0);

		// adjust the layout
		if ( $('#extra').length ) 
		{
			// Subpage
			$('#extra').css('display','block'); // was block
			$('#content').css('margin-right',265); // was block
			$('#navigation').css('margin-left',-1220); // was block
		} 
		else if ( $('#extracolumn').length ) 
		{
			// Homepage
			$('#extracolumn').css('display','block'); // was block
			$('wide').css('margin-right',255);
		}
	}
}

/* cookie to store current browsing mode - default vs mobile */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

$(document).ready(function() {

  var cookieVal = readCookie('mysheet');
  if (cookieVal != 'mobile') { //execute other functions only in default mode
  
    //adjust page width
    hiddenExtras();

    //Setup "information for" on homepage
    if ($("div#infofor").length > 0) {
          $("ul.submenu:first").removeClass('hidden'); //make the first submenu expanded
           $("ul.menu > li.menugroup > a").click(function(){  
              $("ul.submenu").addClass('hidden'); //set all subitems hidden
              $(this).siblings("ul.submenu").toggleClass('hidden');
              if ($(this).parent().hasClass("menugroup")) { 
                    return false; // so that links are not followed when it's the group header is clicked
              }
              else {
                    return true;
              } 
          })
     }

    //Setup feature story pic block
    if ( $('#feature-stories').length ) {
	$('#admin_bar').css('display','none'); 
	$("ul#feature-stories-list").addClass("ui-tabs-nav");
	$("ul#feature-stories-list li[id^='nav-fragment-n']").addClass("ui-tabs-nav-item");
	$("ul#feature-stories-list div.info").addClass("feature-textoverlay");
	$("ul#feature-stories-list img.fullsize").addClass("feature-stories-large-tempimg");
	$("ul#feature-stories-list div.feature-large-pic").addClass("ui-tabs-panel");
	
	$("#feature-stories").tabs({ fx: { opacity: 'toggle', speed: 'fast' } }).tabs('rotate', 5000);
	$("#feature-stories").hover(function(){
		$(this).tabs('rotate', 0, false);
		},function(){
		  $(this).tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000);
		}
	);
    }


    //setup dual scroller 
    if ( $('#programs-events-dual').length ) {
	$(function() {
		$('.carousel').jCarouselLite({
			btnNext: '.next',
			btnPrev: '.prev'
		});
	});
    }

  } //end if cookie
	
});
 





