/* cleartype fix by using our own fadein and fadeout */
/* Source: http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/ */
//-------------------------------------------------------------------------------------------------------
// ClearTypeFadeTo / ClearTypeFadeIn / ClearTypeFadeOut
//
// Custom fade in and fade out functions for jQuery that will work around
// IE's bug with bold text in elements that have opacity filters set when
// also using Window's ClearType text rendering.
//
// New Parameter:
// bgColor    The color to set the background if none specified in the CSS (default is '#fff')
//
// Examples:
// $('div').ClearTypeFadeIn({ speed: 1500 });
// $('div').ClearTypeFadeIn({ speed: 1500, bgColor: '#ff6666', callback: myCallback });
// $('div').ClearTypeFadeOut({ speed: 1500, callback: function() { alert('Fade Out complete') } });
//
// Notes on the interaction of ClearType with DXTransforms in IE7
// http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx
(function($) {
	$.fn.ClearTypeFadeTo = function(options) {
		if (options)
			$(this)
				.show()
				.each(function() {
					if (jQuery.browser.msie) {
						// Save the original background color
						$(this).attr('oBgColor', $(this).css('background-color'));
						// Set the bgColor so that bold text renders correctly (bug with IE/ClearType/bold text)
						//$(this).css({ 'background-color': (options.bgColor ? options.bgColor : '#fff') })
						//$(this).css({ 'background-color': (options.bgColor ? options.bgColor : '#ecf1f7') })
					}
				})
				.fadeTo(options.speed, options.opacity, function() {
					if (jQuery.browser.msie) {
						// ClearType can only be turned back on if this is a full fade in or
						// fade out. Partial opacity will still have the problem because the
						// filter style must remain. So, in the latter case, we will leave the
						// background color and 'filter' style in place.
						if (options.opacity == 0 || options.opacity == 1) {
							// Reset the background color if we saved it previously
							$(this).css({ 'background-color': $(this).attr('oBgColor') }).removeAttr('oBgColor');
							// Remove the 'filter' style to restore ClearType functionality.
							$(this).get(0).style.removeAttribute('filter');
						}
					}
					if (options.callback != undefined) options.callback();
				});
	};

	$.fn.ClearTypeFadeIn = function(options) {
		if (options)
			$(this)
				.css({ opacity: 0 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 1, callback: options.callback });
	};

	$.fn.ClearTypeFadeOut = function(options) {
		if (options)
			$(this)
				.css({ opacity: 1 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 0, callback: options.callback });
	};
})(jQuery);
/*  End of cleat type fix */


if (typeof telcordia == "undefined")
{
	telcordia = {};
}
					
if (typeof telcordia.homepage == "undefined")
{
	telcordia.homepage = {};
}

telcordia.homepage.newsticker = {
    currentNewsItem: 0,
    totalNewsItems: 0,
    intervalLength: 5000,
	containerHeight: 'auto',
	runningClass: 'innerfade',
    changeNewsItem: function(ctr) {
        var currentIndex = telcordia.homepage.newsticker.currentNewsItem;
		//alert('change value by: ' + ctr);
		//alert('current index is: ' +  this.currentNewsItem);
        jQuery("#latestnews li:eq(" + currentIndex + ")").fadeOut("fast", function() {
            jQuery(this).hide()
            });
        if (ctr < 0 && currentIndex == 0) {
            currentIndex = telcordia.homepage.newsticker.totalNewsItems
        }
        currentIndex = (currentIndex + ctr) % telcordia.homepage.newsticker.totalNewsItems;
        jQuery("#latestnews li:eq(" + currentIndex + ")").fadeIn("slow");
        telcordia.homepage.newsticker.currentNewsItem = currentIndex
    },
    setUpNews: function() {
		jQuery('#latestnews .previous-news').html('<a href="" title="Previous News">&nbsp</a>');
		jQuery('#latestnews .previous-news a').click(function() 
		{
			telcordia.homepage.newsticker.changeNewsItem(-1);
			return false
		});
		
		jQuery('#latestnews .next-news').html('<a href="" title="Next News">&nbsp</a>');
		jQuery('#latestnews .next-news a').click(function() 
		{
			telcordia.homepage.newsticker.changeNewsItem(1);
			return false
		});
		
		telcordia.homepage.newsticker.totalNewsItems = jQuery("#latestnews li").length
						
		if (telcordia.homepage.newsticker.totalNewsItems > 1) {
            jQuery("#latestnews ul").css('position', 'relative').css('height', 'auto');
            for (var i = 0; i < telcordia.homepage.newsticker.totalNewsItems; i++) {
               jQuery("#latestnews li:eq(" + i + ")").css('background','#58595b').css('z-index', String(telcordia.homepage.newsticker.totalNewsItems-i)).css('position', 'absolute');
				/* 10-13-2009 commented out jQuery("#latestnews li:eq(" + i + ")").css('background','#ffffff').css('z-index', String(telcordia.homepage.newsticker.totalNewsItems-i)).css('position', 'absolute');*/
				if ( i != 0 )
				{
					//jQuery("#latestnews li:eq(" + i + ")").css('background','#ffffff').css('z-index', String(telcordia.homepage.newsticker.totalNewsItems-i)).css('position', 'absolute').hide();
					jQuery("#latestnews li:eq(" + i + ")").hide();
				}
            };
			
		}
		// jQuery("#latestnews li:eq(" + telcordia.homepage.newsticker.currentNewsItem + ")").fadeIn("slow");
						                
        setInterval(function() {telcordia.homepage.newsticker.changeNewsItem(1)}, telcordia.homepage.newsticker.intervalLength)
	}
};

if (typeof telcordia == "undefined")
{
	telcordia = {};
}
					
if (typeof telcordia.homepage == "undefined")
{
	telcordia.homepage = {};
}

telcordia.homepage.bottomColumn3 = {
    currentItem: 0,
    totalItems: 0,
    changeItem: function(ctr,evt) {
        var currentIndex = telcordia.homepage.bottomColumn3.currentItem;
		//alert('change value by: ' + ctr);
		//alert('current index is: ' +  this.currentNewsItem);
        jQuery("#column33 li:eq(" + currentIndex + ")").hide();
		
		var previousIndex = currentIndex;
        if (ctr < 0 && currentIndex == 0) {
            currentIndex = telcordia.homepage.bottomColumn3.totalItems
        }
        currentIndex = (currentIndex + ctr) % telcordia.homepage.bottomColumn3.totalItems;
        jQuery("#column33 li:eq(" + currentIndex + ")").ClearTypeFadeIn("fast");
        telcordia.homepage.bottomColumn3.currentItem = currentIndex
		if ( typeof(evt) != 'undefined') {
				var node = jQuery("#column33 li:eq(" + currentIndex + ")");
				omnitureTrackClick(node,"Upcoming Events",previousIndex, currentIndex);
		}
    },
    setUpColumn: function() {
		jQuery("#column33 .previous-col3").html('<a href="" title="Previous">&nbsp</a>');
		jQuery("#column33 .previous-col3 a").click(function() 
		{
			telcordia.homepage.bottomColumn3.changeItem(-1,"previous");
			return false
		});
		
		jQuery('#column33 .next-col3').html('<a href="" title="Next">&nbsp</a>');
		jQuery('#column33 .next-col3 a').click(function() 
		{
			telcordia.homepage.bottomColumn3.changeItem(1,"next");
			return false
		});
		
		telcordia.homepage.bottomColumn3.totalItems = jQuery("#column33 li").length
		jQuery("#column33 ul").css('position', 'relative').css('height', 'auto');
		for (var i = 0; i < telcordia.homepage.bottomColumn3.totalItems; i++) {
                jQuery("#column33 li:eq(" + i + ")").css('z-index', String(telcordia.homepage.bottomColumn3.totalItems-i)).css('position', 'relative');
				if ( i != 0 )
				{
					jQuery("#column33 li:eq(" + i + ")").hide();
				}
        };
						
		/*if (telcordia.homepage.bottomColumn3.totalItems > 1) {
            jQuery("#column33 ul").css('position', 'relative').css('height', 'auto');
            for (var i = 0; i < telcordia.homepage.bottomColumn3.totalItems; i++) {
                jQuery("#column33 li:eq(" + i + ")").css('background','#ffffff').css('z-index', String(telcordia.homepage.bottomColumn3.totalNewsItems-i)).css('position', 'absolute');
				if ( i != 0 )
				{
					jQuery("#column33 li:eq(" + i + ")").hide();
				}
            };
			
		}*/
		// jQuery("#latestnews li:eq(" + telcordia.homepage.newsticker.currentNewsItem + ")").fadeIn("slow");
	}
};

telcordia.homepage.bottomColumn2 = {
    currentItem: 0,
    totalItems: 0,
    changeItem: function(ctr,evt) {
        var currentIndex = telcordia.homepage.bottomColumn2.currentItem;
		//alert('change value by: ' + ctr);
		//alert('current index is: ' +  this.currentNewsItem);
        jQuery("#column22 li:eq(" + currentIndex + ")").hide();
		
		var previousIndex = currentIndex;
        if (ctr < 0 && currentIndex == 0) {
            currentIndex = telcordia.homepage.bottomColumn2.totalItems
        }
        currentIndex = (currentIndex + ctr) % telcordia.homepage.bottomColumn2.totalItems;
        jQuery("#column22 li:eq(" + currentIndex + ")").fadeIn("fast");
        telcordia.homepage.bottomColumn2.currentItem = currentIndex
		if ( typeof(evt) != 'undefined') {
				var node = jQuery("#column22 li:eq(" + currentIndex + ")");
				omnitureTrackClick(node,"Middle Column",previousIndex, currentIndex);
		}
    },
    setUpColumn: function() {
		jQuery("#column22 .previous-col2").html('<a href="" title="Previous">&nbsp</a>');
		jQuery("#column22 .previous-col2 a").click(function() 
		{
			telcordia.homepage.bottomColumn2.changeItem(-1,"previous");
			return false
		});
		
		jQuery('#column22 .next-col2').html('<a href="" title="Next">&nbsp</a>');
		jQuery('#column22 .next-col2 a').click(function() 
		{
			telcordia.homepage.bottomColumn2.changeItem(1,"next");
			return false
		});
		
		telcordia.homepage.bottomColumn2.totalItems = jQuery("#column22 li").length
		jQuery("#column22 ul").css('position', 'relative').css('height', 'auto');
		for (var i = 0; i < telcordia.homepage.bottomColumn3.totalItems; i++) {
                jQuery("#column22 li:eq(" + i + ")").css('z-index', String(telcordia.homepage.bottomColumn2.totalItems-i)).css('position', 'relative');
				if ( i != 0 )
				{
					jQuery("#column22 li:eq(" + i + ")").hide();
				}
        };
						
		// jQuery("#latestnews li:eq(" + telcordia.homepage.newsticker.currentNewsItem + ")").fadeIn("slow");
	}
};

function omnitureTrackClick(node,label, previousIdx, currentIdx) {
			
		if(typeof(s) != 'undefined') {
			var linkname = s.pageName + " -- " +label+ " -- " + previousIdx + " to " + currentIdx;
			//alert("s.t1 ->" + linkname);
			s.linkTrackVars="None"
			s.linkTrackEvents="None"
			s.tl(node,'o',linkname);
		}
}