jQuery(document).ready( function() {
	
	jQuery(".tabContent").each(function() {
	
		jQuery(this).unwrap().unwrap();
	
	});
	
	jQuery(".tabContent:first").prev().remove();
	jQuery(".tabContent:first").unwrap().unwrap();
	
	var tabContent = jQuery("#tabContent");
	
	tabContent.children(".tabContent").each( function(i, selected) {
	
		jQuery("#tabNavigation").append("<div class='tabNavigation' />");
	
	});

	var tabContainer = jQuery("#tabContainer");
	var tabNavigation = jQuery("#tabNavigation .tabNavigation");
	var tabIndex = 0;
	var tabWidth = jQuery("#tabContainer").width();
	var tabTimeout;

	tabNavigation.click( function() {
	
		clearTimeout(tabTimeout);
		
		tabIndex = tabNavigation.index(jQuery(this));
		
		tabNavigation.removeClass("active");
		jQuery(this).addClass("active");
		
		tabContent.animate({
			marginLeft: ( 0 - ( tabIndex * tabWidth ) )
		},500);
		
		tabAuto(tabIndex);
	
	});
	
	function tabAuto(tabIndex2)
	{
		tabTimeout = setTimeout( function() {
		
			tabIndex = tabIndex2 + 1;
			
			if ( tabIndex > (tabNavigation.size() - 1) )
			{
				tabIndex = 0;
			}
			
			tabNavigation.removeClass("active");
			jQuery(tabNavigation[tabIndex]).addClass("active");
			
			tabContent.animate({
				marginLeft: ( 0 - ( tabIndex * tabWidth ) )
			},500);
			
			tabAuto(tabIndex);
		
		},5000);
	}
	
	jQuery(tabNavigation[0]).click();

	tabContainer.mouseenter( function() {
	
		clearTimeout(tabTimeout);
	
	});

	tabContainer.mouseleave( function() {
	
		tabAuto(tabIndex);
	
	});
	
	jQuery(".mainAccordion").each(function() {
							
		jQuery(this).unwrap().unwrap();
	
	});
	
	jQuery(".mainAccordion:first").prev().remove();
	jQuery(".mainAccordion:first").unwrap().unwrap();
	jQuery(".mainAccordion:first").addClass("selected");
	
	var mainAccordion = jQuery("#mainAccordion");
	var mainAccordionTrigger = mainAccordion.children(".mainAccordion");
	var mainAccordionContent = mainAccordion.children("div");
	var mainAccordionIndex = -1;
	
	mainAccordion.accordion({ 
		header: '.mainAccordion',
		active: '.selected',
		autoheight: false,
		selectedClass: "selected"
	});
	
	mainAccordionTrigger.click( function() {
	
		setTimeout( function() {
			Cufon.refresh();				 
		},10);
		
	});

	var flashContainer = jQuery("#flashContainer");
	var flashNavigation = jQuery("#flashNavigation .flashNavigation");
	var flashContent = jQuery("#flashContent");
	var flashIndex = 0;
	var flashHeight = jQuery("#flashContainer").width();
	var flashTimeout;
	var flashNavigationLeft = jQuery(".flashNavigationLeft");
	var flashNavigationRight = jQuery(".flashNavigationRight");
	var flashHoverContainer = jQuery("#flashHoverContainerLeft");
	var flashHoverTextContainer = jQuery("#flashHoverContainerRepeat");
	var flashPointer = jQuery("#flashPointer");
	var flashHoverLeft;
	var flashHoverTop;
	
	jQuery("#flashNavigation .flashNavigation").each(function() {
							
		jQuery(this).unwrap().unwrap();
	
	});
	
	jQuery("#flashNavigation .flashNavigation:first").prev().remove();
	jQuery("#flashNavigation .flashNavigation:first").unwrap().unwrap();
	
	jQuery(".flashContent").each(function() {
							
		jQuery(this).unwrap().unwrap();
	
	});
	
	jQuery(".flashContent:first").prev().remove();
	jQuery(".flashContent:first").unwrap().unwrap();	
	
	flashNavigation.click( function() {
									
		clearTimeout(flashTimeout);
	
		flashIndex = flashNavigation.index(jQuery(this));
		
		flashNavigation.removeClass("active");
		jQuery(this).addClass("active");
		
		flashContent.animate({
			marginLeft: ( 0 - ( flashIndex * flashHeight ) )
		},710);
		
		flashAuto(flashIndex);
	
	});
	
	flashNavigation.mouseenter( function() {
		
		flashHoverLeft = parseInt(jQuery(this).position().left);
		flashHoverTop = parseInt(jQuery(this).position().top);
		
		flashHoverContainer.css("marginLeft",(flashHoverLeft + flashNavLeftPosition));
		flashHoverContainer.css("marginTop",(flashHoverTop + 218));
		
		flashPointer.css("marginLeft",(flashHoverLeft + flashNavLeftPosition + 11));
		flashPointer.css("marginTop",(flashHoverTop + 237));
		
		flashHoverTextContainer.text(jQuery(this).attr("title"));
		
		flashHoverContainer.css("display","block");
		flashPointer.css("display","block");
		
	});
	
	flashNavigation.mouseleave( function() {
		
		flashHoverContainer.css("display","none");
		flashPointer.css("display","none");
		
	});
	
	flashNavigationLeft.click( function() {
		
		flashIndex--;
		
		if ( flashIndex < 0 )
		{
			flashIndex = ( flashNavigation.size() - 1 )
		}
		
		jQuery(flashNavigation[flashIndex]).click();
		
	});
	
	flashNavigationRight.click( function() {
		
		flashIndex++;
		
		if ( flashIndex > ( flashNavigation.size() - 1 ) )
		{
			flashIndex = 0
		}
		
		jQuery(flashNavigation[flashIndex]).click();
		
	});
	
	function flashAuto(flashIndex2)
	{
		flashTimeout = setTimeout( function() {
		
			flashIndex = flashIndex2 + 1;
			
			if ( flashIndex > (flashNavigation.size() - 1) )
			{
				flashIndex = 0;
			}
			
			flashNavigation.removeClass("active");
			jQuery(flashNavigation[flashIndex]).addClass("active");
			
			flashContent.animate({
				marginLeft: ( 0 - ( flashIndex * flashHeight ) )
			},500);
			
			jQuery("#testScript").html(flashIndex + "");
			
			flashAuto(flashIndex);
		
		},10000);
	}
	
	jQuery(flashNavigation[0]).click();
	
	var flashNavLeftPosition = ( jQuery("#flashContainer").width() - jQuery("#flashNavigationLeft").width() ) / 2
	
	jQuery("#flashNavigationLeft").css("marginLeft",flashNavLeftPosition);
	
	jQuery(".mainAnnouncement").each(function() {
							
		jQuery(this).unwrap().unwrap();
	
	});
	
	jQuery(".mainAnnouncement:first").prev().remove();
	jQuery(".mainAnnouncement:first").unwrap().unwrap();
	
	var mainAnnouncement = jQuery(".mainAnnouncement");
	var mainAnnouncementTimeOut;
	
	mainAnnouncement.each( function() {
		
		jQuery(this).css("opacity","0");
		
	});
	
	function announcementSlider(announcementSliderIndex)
	{
		
		announcementSliderIndex = announcementSliderIndex * 1;
		
		if ( announcementSliderIndex != 0 )
		{
			jQuery(mainAnnouncement[announcementSliderIndex - 1]).animate({
	
				marginLeft: '0px',
				opacity: '0'
			
			},500);
			
			setTimeout( function() {
			
				jQuery(mainAnnouncement[announcementSliderIndex - 1]).css("display","none")
					
			},580 );
		}
		else
		{
			
			jQuery(mainAnnouncement[mainAnnouncement.size() - 1]).animate({
	
				marginLeft: '0px',
				opacity: '0'
			
			},500);
			
			setTimeout( function() {
			
				jQuery(mainAnnouncement[mainAnnouncement.size() - 1]).css("display","none")
					
			},580 );
			
		}
		
		jQuery(mainAnnouncement[announcementSliderIndex]).css("display","block").animate({
		
			marginLeft: '10px',
			opacity: '1'
		
		},500);
		
		var announcementSliderIndex2 = announcementSliderIndex + 1;
		
		if ( announcementSliderIndex2 > (mainAnnouncement.size() - 1) )
		{
			announcementSliderIndex2 = 0;
		}
		
		mainAnnouncementTimeOut = setTimeout( function() {
			
			announcementSlider(announcementSliderIndex2);
				
		},10000 );
	}
	
	announcementSlider(0);

});
