function showTimeMessage() {
	day = new Date();
	hr = day.getHours();
	if (hr >= 6 && hr <= 11) {document.write("Good Morning")};
	if (hr >= 12 && hr <= 17) {document.write("Good Afternoon")};
	if ((hr >= 0 && hr<= 5) || (hr >= 18 && hr<= 23)) {document.write("Good Evening")};
}

function showDate() {
	m1= new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	today= new Date();
	day= today.getDate();
	year= today.getYear();
	if (year < 2000) {year = year + 1900};

	end = "th";
	if (day==1||day==21||day==31) end="st";
	if (day==2||day==22) end="nd";
	if (day==3||day==23) end="rd";
	day=day+end;

	var fullDate = (day+ " "+m1[today.getMonth()]+" "+year);
	document.write(fullDate);
}

function flashMovie(name,width,height) {
	var strString = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width='+width+' height='+height+'><param name=movie value="'+name+'"><param name=quality value=high><param name="wmode" value="transparent"><embed src="'+name+'" quality=high wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width='+width+' height='+height+'></embed></object>';
	document.write (strString);
}

function scrollContent() {
	scrollContentPos = 0;
	document.getElementById('scrollingContent').innerHTML = document.getElementById('scrollingContent').innerHTML + document.getElementById('scrollingContent').innerHTML;
	contentWidth = document.getElementById('scrollingContent').clientWidth;
	intInterval = setInterval("moveContent()",30);
}

function moveContent() {
	scrollContentPos--;
	document.getElementById('scrollingContent').style.left = scrollContentPos + "px";
	if (scrollContentPos == (-contentWidth/2)) {
		scrollContentPos = 0;
	}
}

function showDIV(nameDIV, fileName) {
    document.getElementById(nameDIV).style.visibility = "visible";
    if (fileName != null) {
        document.getElementById(nameDIV + 'Content').innerHTML = "<iframe id=\"iframePopup\" name=\"iframePopup\" src =\"/" + fileName + ".html\" width=\"500\" height=\"350\" frameborder=\"0\"></iframe>";
    }
}

function hideDIV(nameDIV) {
    document.getElementById(nameDIV).style.visibility = "hidden";
}


// Twitter display functions
String.prototype.linkify = function () {
    return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function (m) { return m.link(m); });
};

function relative_time(time_value) {
    var values = time_value.split(" ");
    time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
    var parsed_date = Date.parse(time_value);
    var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
    var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
    delta = delta + (relative_to.getTimezoneOffset() * 60);

    var r = '';
    if (delta < 60) {
        r = 'a minute ago';
    } else if (delta < 120) {
        r = 'couple of minutes ago';
    } else if (delta < (45 * 60)) {
        r = (parseInt(delta / 60)).toString() + ' minutes ago';
    } else if (delta < (90 * 60)) {
        r = 'an hour ago';
    } else if (delta < (24 * 60 * 60)) {
        r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
    } else if (delta < (48 * 60 * 60)) {
        r = '1 day ago';
    } else {
        r = (parseInt(delta / 86400)).toString() + ' days ago';
    }

    return r;
}

function twitter_callback() { return true; }

function slideShow(frameId, frameCount, fadeDelay, fadeInterval) {

    this.frameId = frameId;
    this.frameCount = frameCount;
    this.fadeDelay = fadeDelay;
    this.fadeInterval = fadeInterval;
    this.currentFrame = 0;
    this.oldFrame = 0;
    this.fading = false;
    this.timeoutID = 0;

    this.nextFrame = function () {
        if (!this.fading) {
            this.oldFrame = this.currentFrame;
            this.currentFrame++;
            if (this.currentFrame > this.frameCount)
                this.currentFrame = 1;
            this.startFade();
        }
    };

    this.startFade = function () {
        clearTimeout(this.timeoutID);
        this.timeoutID = 0;
        this.fading = true;
        $('#' + this.frameId + this.oldFrame).fadeOut(this.fadeDelay);
        var me = this;
        $('#' + this.frameId + this.currentFrame).fadeIn(this.fadeDelay, function () { me.fadeComplete.call(me); });
    };

    this.fadeComplete = function () {
        this.fading = false;
        var me = this;
        this.timeoutID = setTimeout(function () { me.nextFrame.call(me); }, this.fadeInterval);
    };

    for (var i = 1; i <= this.frameCount; i++) {
        $('#' + this.frameId + i).css('position', 'absolute');
        if (i > 1)
            $('#' + this.frameId + i).css('display', 'none');
    }

    this.nextFrame.call(this);
}
