//ON DOM READY CALLS
jQuery(document).ready(function () {

	
	jQuery("#loginUsername").focus(function () {
		document.getElementById('loginUsername').style.background = '#ffffff';
		//console.log('loginUsername:focus');
	});
	
	jQuery("#loginUsername").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_email.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('loginUsername').style.background = bgimage;
		//console.log('loginUsername:blur');
	});
	
	jQuery("#loginPass").focus(function () {
		document.getElementById('loginPass').style.background = '#ffffff';
		//console.log('loginPass:focus');
	});
	
	jQuery("#loginPass").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_password.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('loginPass').style.background = bgimage;
		//console.log('loginPass:blur');
	});
	
	jQuery("#Login_ID").focus(function () {
		document.getElementById('Login_ID').style.background = '#ffffff';
		//console.log('Login_ID:focus');
	});
	
	jQuery("#Login_ID").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_enews.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('Login_ID').style.background = bgimage;
		//console.log('Login_ID:blur');
	});
	
	jQuery("#headerCaroselContainer").easySlider({
		auto: false, 
		continuous: true,
		vertical: false,
		prevId: 'prevBtn2',
		nextId: 'nextBtn2'
	});
	
	jQuery("#huskerpixContent").easySlider({
		auto: false, 
		continuous: true,
		prevId: 'prevBtn3',
		nextId: 'nextBtn3'
	});
	
	pngfix();
	centerMenu();
	//centerHeader();
	
	jQuery(window).resize(function () { 
    	centerMenu();
    	//centerHeader();
    });
    
    jQuery(window).scroll(function () { 
      centerMenu();
      //centerHeader();
    });
	
    tickerTimer = setTimeout("tickerScroll();", 8000);
    
});
var tickerTimer;
var tickerMargin = 0;
var tickerDiff = 29;
if (navigator.appName == "Microsoft Internet Explorer")
	tickerDiff = 32;

function tickerScroll() {
	tickerAction();
}

function tickerAction() {
	tickerMargin = tickerMargin - tickerDiff;
	if (-tickerMargin >=  jQuery('#tickerUl').height()) 
		tickerMargin = 0;
	jQuery("#tickerUl").css('margin-top', tickerMargin+'px');
	tickerTimer = setTimeout("tickerScroll();", 8000);
}

function centerMenu() {
	windowW = jQuery(window).width();
	menuW = jQuery('#menu').width();
	posLeft = ((windowW - menuW) / 2);
	posLeft = Math.round(posLeft);
	jQuery('#menu').css("left", posLeft + "px");
}

function centerHeader() {
	windowW = jQuery(window).width();
	menuW = jQuery('#headerPosContainer').width();
	posLeft = ((windowW - menuW) / 2) - 27;
	posLeft = Math.round(posLeft);
	jQuery('#headerPosContainer').css("left", posLeft + "px");
}

function TopTab(num) {
	jQuery("#TabBox1 .tab-buttons").removeClass("active");
	jQuery("#TabBox1 .tab-buttons:eq("+num+")").addClass("active");
	jQuery("#TabBox1 .tab-content").fadeOut(500);
	setTimeout('jQuery("#TabBox1 .tab-content:eq('+num+')").fadeIn(500)',510);
}

function BottomTab(num) {
	jQuery("#TabBox2 .tab-buttons").removeClass("active");
	jQuery("#TabBox2 .tab-buttons:eq("+num+")").addClass("active");
	jQuery("#TabBox2 .tab-content").fadeOut(500);
	setTimeout('jQuery("#TabBox2 .tab-content:eq('+num+')").fadeIn(500)',510);
}

/**************************************************************************
START ROTATOR
**************************************************************************/
var rotate = true;

var rotate_current = 1;
var rotate_current2 = 1;
var rotate_end = 4;
var rotate_timer;

function Rotate() {
	if (rotate) {
		document.getElementById('main-content-'+rotate_current).style.display='none';
		document.getElementById('rotatorarrow'+rotate_current).style.display='none';
		document.getElementById('sub-image-'+rotate_current).style.border='none';
		document.getElementById('sub-image-'+rotate_current).style.marginBottom='7px';
		
		rotate_current++;
		if (rotate_current > rotate_end)
			rotate_current = 1;
			
		document.getElementById('main-content-'+rotate_current).style.display='block';
		document.getElementById('rotatorarrow'+rotate_current).style.display='block';
		document.getElementById('sub-image-'+rotate_current).style.border='2px solid #fff';
		document.getElementById('sub-image-'+rotate_current).style.marginBottom='2px';
		
		rotate_timer = setTimeout("Rotate();", 8000);
	}
}

function RotateTo(num) {
	clearTimeout(rotate_timer);
	document.getElementById('main-content-'+rotate_current).style.display='none';
	document.getElementById('rotatorarrow'+rotate_current).style.display='none';
	document.getElementById('sub-image-'+rotate_current).style.border='none';
	document.getElementById('sub-image-'+rotate_current).style.marginBottom='7px';
	
	rotate_current = num;
		
	document.getElementById('main-content-'+rotate_current).style.display='block';
	document.getElementById('rotatorarrow'+rotate_current).style.display='block';
	document.getElementById('sub-image-'+rotate_current).style.border='2px solid #fff';
	document.getElementById('sub-image-'+rotate_current).style.marginBottom='2px';
	
	rotate = false;
}

function RotateTo2(num) {
	document.getElementById('main-content2-'+rotate_current2).style.display='none';
	document.getElementById('rotatorarrow2'+rotate_current2).style.display='none';
	document.getElementById('sub-image2-'+rotate_current2).style.border='none';
	document.getElementById('sub-image2-'+rotate_current2).style.marginBottom='7px';
	
	rotate_current2 = num;
		
	document.getElementById('main-content2-'+rotate_current2).style.display='block';
	document.getElementById('rotatorarrow2'+rotate_current2).style.display='block';
	document.getElementById('sub-image2-'+rotate_current2).style.border='2px solid #fff';
	document.getElementById('sub-image2-'+rotate_current2).style.marginBottom='2px';
	
	rotate = false;
}


//rotate_timer = setTimeout("Rotate();", 8000);

/**************************************************************************
END ROTATOR
**************************************************************************/

  function showRotator(){
      document.getElementById('rotatorOn').style.display='block';
      document.getElementById('rotatorTab').style.display='block';
      
      document.getElementById('calendarOn').style.display='none';
      document.getElementById('eventCalTab').style.display='none';
      
      document.getElementById('topVideoOn').style.display='none';
      document.getElementById('topVideosTab').style.display='none';
  }
  
  function showCalendar(){
      document.getElementById('rotatorOn').style.display='none';
      document.getElementById('rotatorTab').style.display='none';
      
      document.getElementById('calendarOn').style.display='block';
      document.getElementById('eventCalTab').style.display='block'; 
      
      document.getElementById('topVideoOn').style.display='none';
      document.getElementById('topVideosTab').style.display='none';
  }
  
  function showTopVideo(){
      document.getElementById('rotatorOn').style.display='none';
      document.getElementById('rotatorTab').style.display='none';
      
      document.getElementById('calendarOn').style.display='none';
      document.getElementById('eventCalTab').style.display='none'; 
      
      document.getElementById('topVideoOn').style.display='block';
      document.getElementById('topVideosTab').style.display='block';
      
      playOnHigh();
  }
  
  function showGames() {
  	  document.getElementById('righttopStories').style.display='none';
      document.getElementById('righttopStoriesContent').style.display='none';
      
      document.getElementById('righttopGames').style.display='block';
      document.getElementById('righttopGamesContent').style.display='block'; 
  }
  
  function showStories() {
  	  document.getElementById('righttopStories').style.display='block';
      document.getElementById('righttopStoriesContent').style.display='block';
      
      document.getElementById('righttopGames').style.display='none';
      document.getElementById('righttopGamesContent').style.display='none'; 
  }
  
  /*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

function pngfix() {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	//alert(version);
	//alert(document.body.filters);
	if ((version >= 5.5) && (document.body.filters) && version < 7.0)
	//alert('if statement'); 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	      	//alert('png found');
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
}
  