
var homePageTabCookName = "homePageTabCook";

//<![CDATA[
		$(function(){
			// Initialize the scrolling banner.
			$('div.scrollable div.items div').each(function(i) {
				$('div.navi').append('<a />');
			});

			$('div.navi a:last').addClass('last');

			// Initialize the scrolling banner.
			$('div.navi').tabs('div.scrollable div.items > div', {
				current: 'active',
				effect: 'fade',
				fadeOutSpeed: 'slow',
				rotate: true,
				onClick: function(e) {
					var curPane = this.getCurrentPane();
					var altText = $('a', curPane).attr('alt');
					var hrefText = $('a', curPane).attr('href');
					var tooltipText = altText + ' - ' + hrefText;
					$('div.banner-rotate').attr('title', tooltipText);
					//$('div.banner-rotate').attr('alt', tooltipText);
					//$('div.banner-rotate').attr('title', $('a', curPane).attr('href'));
				}
			}).slideshow({
				autoplay: true,
				interval: 5000
			});

			$('div.navi').appendTo('div.mask').css('width', $('div.scrollable div.items > div').size() * 24 + 'px');

			// Initialize the tabbed content area.
			$('div.tabbedpanes ul.tabs').tabs('div.tabbedpanes .panes .pane', {
				onClick: function(tab) {
					var curTab = tab + 1;
					var curTabHeight = $('div.tabbedpanes div.panes div.pane' + curTab).height();
					var curNoteHeight = $('div.subnote', 'div.tabbedpanes div.panes div.pane' + curTab).height();

					if(curNoteHeight) {
						/* Take the height of the current tab and subtract the
						height of the "subnote" content. With this value, we
						need to adjust the positioning of the background image-
						subtracting the height of it (less 10 for layout
						reasons). */
						$('div.tabbedpanes div.panes div.pane' + curTab).css("backgroundPosition", "100% " + (curTabHeight -  curNoteHeight - 84) + "px");
					}
				}
			});

			var tabPanelNav = $('div.tabbedpanes ul.tabs');

			$('div.tabbedpanes ul.tabs li a').click(function() {
				var idx = $('div.tabbedpanes ul.tabs li a').index(this);
				$(tabPanelNav).attr('class', 'tabs tabs-active-' + (idx + 1));
				
				var tmp = readCookie(homePageTabCookName);
				if( null!=tmp && (tmp!=(idx+1)) ) {
					document.getElementById(("tab_pane"+tmp)).style.display="none";
					document.getElementById(("tab_pane"+(idx+1))).style.display="block";
				}
				document.cookie = homePageTabCookName+"="+(idx+1)+"; path=/";
			});

			$('div.mask').click(function(e){
				if(e.target.className == "mask")
				{
					var linkTarget = $('div.scrollable div.items div:visible a').attr('target');
					var linkHref =  $('div.scrollable div.items div:visible a').attr('href');

					if (linkTarget == "_blank" || linkTarget == "_new" )
						window.open(linkHref);
					else
						document.location.href = linkHref;
				}
			});
		});
		
		$(document).ready(function() {
			createHomePageTabCookie();
		});
	//]]>

	function createHomePageTabCookie() {
		var el = document.getElementById("tabsContainer");
		var tabDataEl = null;
		var tabCookVal = readCookie(homePageTabCookName);

		if( null!=tabCookVal ) {
			el.className = ("tabs tabs-active-"+tabCookVal);
			tabDataEl = document.getElementById(("tab_pane"+tabCookVal));
			tabDataEl.style.display = "block";
			document.getElementById(("tabAnchor"+tabCookVal)).className = "tab current";

			for(i=1;i<=4;i++) {
				if( tabCookVal==i )
					continue;
				tabDataEl = document.getElementById(("tab_pane"+i));	
				tabDataEl.style.display = "none";
				document.getElementById(("tabAnchor"+i)).className = "tab";
			}
		} else {
			return;
		}
	}