$(document).ready(function () {

    var intCnt = 0;
    $('#event div').children().each(function () {
        var child = $(this);
        if (child.is('span')) {
            var dteEvt = new Date(child.html());
            var dteNow = new Date();
            if (dteEvt.getTime() >= dteNow.getTime()) {
                child.html(getClockTime(dteEvt));
                intCnt++;
            } else {
                child.parent().hide();
            }
        }

        if (intCnt > 2) {
            child.parent().hide();
        }
    });

    $('.pg1').click(function(){
        var target = $('#page1');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg2').click(function(){
        var target = $('#page2');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg3').click(function(){
        var target = $('#page3');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg4').click(function(){
        var target = $('#page4');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg5').click(function(){
        var target = $('#page5');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg6').click(function(){
        var target = $('#page6');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg7').click(function(){
        var target = $('#page7');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });
    $('.pg8').click(function(){
        var target = $('#page8');
        if (target.length)
        {
            var left = target.offset().left - 20;
			if (left <= 0) { left = 0; };
            $('html,body').animate({scrollLeft: left}, 1000);
            return false;
        }
    });

    $('.ppl').click(function () {
        $('div.pplProf').hide();
        $('#' + $(this).attr('id') + "Prof").show();
        return false;
    });

    $('.clnt').click(function () {
        $('div.clntProf').hide();
        $('#' + $(this).attr('id') + "Clnt").show();
        bindSlides();
        return false;
    });
});

(function ($) {
    var intSpeed = 3;
    var intDisplayCount = 2;
    var intBoxHeight = 212;
    var intRotateHeight = 0;
		var intInitialTop = 0;
    var intTimer;
    $(function () {
				intInitialTop = $('#news .news-holder').offset().top;
        intRotateHeight = -1 * $('#news .news-holder div').length * intBoxHeight;
        $('#news .news-holder div:lt(' + intDisplayCount + ')').each(function () {
            $(this).clone().appendTo('#news .news-holder');
        });
        startRotation();
        $('#news .news-holder div').mouseenter(function () {
            stopRotation();
        }).mouseleave(function () {
            startRotation();
        });
			var intThumbCount = $('.thumbnailholder ul li').length;
			var intCurThumb = 0;
			var intDisplayCount = 6;
			$('#pg5up').click(function(e) {
				if ((intCurThumb + 1) <= (intThumbCount - intDisplayCount)) {
					intCurThumb++;
					moveThumbnails(intCurThumb);
				}
				e.preventDefault();
			});
			$('#pg5down').click(function(e) {
				if ((intCurThumb - 1) > -1) {
					intCurThumb--;
					moveThumbnails(intCurThumb);
				}
				e.preventDefault();
			});
			function moveThumbnails(intNewPos) {
				$('.thumbnailholder ul').animate({top: (intNewPos * -129)},200,function() {

				});
			}
    });
    function startRotation() {
        intTimer = setInterval(function () {
            $('#news .news-holder').animate({
                top: '-=' + intBoxHeight
            }, 2000, function () {
                if ($(this).offset().top <= (intRotateHeight + intInitialTop)) {
                    $(this).css('top', '0px');
                }
            });
        }, (intSpeed * 1000));
    }
    function stopRotation() {
        clearInterval(intTimer);
    }
})(jQuery);

function getClockTime(now)
{
	var hour   = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds();
	var month = now.getMonth() + 1;
	var day = now.getDate();
	var year = now.getFullYear();
	var ap = "AM";
	if (hour   > 11) { ap = "PM";             }
	if (hour   > 12) { hour = hour - 12;      }
	if (hour   == 0) { hour = 12;             }
	if (hour   < 10) { hour   = "0" + hour;   }
	if (minute < 10) { minute = "0" + minute; }
	if (second < 10) { second = "0" + second; }
	var timeString = month + 
					"/" + 
					day + 
					"/" + 
					year + 
					" " + 
					hour +
					':' +
					minute +
					" " +
					ap;
	return timeString;
}

function bindSlides() {
    $('#baxterImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'baxterMenu'
    });

    $('#contourImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'contourMenu'
    });

    $('#divicixImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'divicixMenu'
    });

    $('#gogirlImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'gogirlMenu'
    });

    $('#hospiraImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'hospiraMenu'
    });

    $('#optumImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'optumMenu'
    });

    $('#poetImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'poetMenu'
    });

    $('#visioneaseImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'visioneaseMenu'
    });

    $('#vtiImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'vtiMenu'
    });

    $('#ziaImg').wslide({
        width: 567,
        height: 544,
        horiz: true,
        autolink: 'ziaMenu'
    });
}


