﻿$(document).ready(function() {
    var halt = false;
    var intervalId;
    ClearAnchorFocus();
    RegisterHover();

    function StartAnimate() {
        $('#noticeblock').children(':first').animate({
            marginTop: '-17px'
        }, 800, AnimateEnd);
    }

    function AnimateEnd() {
        var first = $('#noticeblock').children(':first');
        $('#noticeblock')[0].appendChild(first.removeAttr('style').remove().clone(true)[0]);
    }

    function RegisterHover(e) {
        $('#noticeblock').hover(
				function() {
				    if (halt == false) {
				        halt = true;
				        window.clearInterval(intervalId);
				    }
				},
				function() {
				    if (halt == true) {
				        halt = false;
				        intervalId = window.setInterval(StartAnimate, 4000);
				    }
				});
    }
    function ClearAnchorFocus() {
        $('#noticeblock a').focus(function() { $(this)[0].blur(); });
    }
    // start
    intervalId = window.setInterval(StartAnimate, 4000);
	
	$("#tabA > ul").tabs({fx: { height: 'toggle', duration: 'fast' },cache:true});
	$("#tabB > ul").tabs({fx: { height: 'toggle', duration: 'fast' },cache:true});
	$("#tabC > ul").tabs({fx: { height: 'toggle', duration: 'fast' },cache:true});
	new Accordian('accordion_basic', 5, 'header_highlight');
});