/*
Document: uwmain.js
Author: Derek De Jager
Created on: May 13, 2008
Description: Javascript for United Way
Last Modified: May 14, 2008
 
*/
window.onload = function(){
    var myClock = new DigitalClock(document.getElementById("date"),12);
    
    SDEffect(document.getElementById("headertext"));
    ShowEffect(document.getElementById("welcomepic"));
    ShowEffect(document.getElementById("uwlogopic"));
    
}

    
   function DropOutEffect(element){
       new Effect.DropOut(element, {duration:3});
    }
    
    function SDEffect(element){
       new Effect.SlideDown(element, {duration:2.5});
    }

   function ShowEffect(element){
       new Effect.Appear(element, 
       {duration:3, from:0, to:3.0});
    }
Date.prototype.toDayOfWeekString = function(){
        if(this.getDay() == 0){
            return("Sunday");
        }else if(this.getDay() == 1){
            return("Monday");
        }else if(this.getDay() == 2){
            return("Tuesday");
        }else if(this.getDay() == 3){
            return("Wednesday");
        }else if(this.getDay() == 4){
            return("Thursday");
        }else if(this.getDay() == 5){
            return("Friday");
        }else{ 
            return("Saturday");
        }
}

Date.prototype.toSlashDateString = function(){
    var month = this.getMonth();
    month++;
    var day = this.getDate();
    var year = this.getFullYear();
    
    return(month + "/" + day + "/" + year);     
}

Date.prototype.toTimeString = function(clockType){
    if (clockType == 12){
	var ampm = "";
	var curr_hour = this.getHours();
	var curr_min = this.getMinutes();
	var curr_sec = this.getSeconds();
	if (curr_hour < 12)
	{
	    ampm = "AM";
	}
	else
	{
	    ampm = "PM";
	}
	if (curr_hour == 0)
	{
	    curr_hour = 12;
	}
	if (curr_hour > 12)
	{
	curr_hour = curr_hour - 12;
	}
	
	//2 digit minutes
	curr_min = curr_min + "";

	if (curr_min.length == 1)
	{
	curr_min = "0" + curr_min;
	}
	//2 digit seconds
	curr_sec = curr_sec + "";

	if (curr_sec.length == 1)
	{
	    curr_sec = "0" + curr_sec;
	}
	return(curr_hour + ":" + curr_min + ":" + curr_sec + " " + ampm);
   
    }
    else{
	return("kk:mm:ss");
    }   
}

String.prototype.initCaps = function(){
    var text = this.replace(/\b\w+\b/g, function(word){
        return (word.substring(0,1).toUpperCase() + word.substring(1,word.length).toLowerCase());
    });
    return text;
}

function BDEffect(element){
    new Effect.BlindDown(element, {duration:3});
}

function BUEffect(element){
       new Effect.BlindUp(element, {duration:3});
}

