// Verbose Debugging.
var V_DEBUG = false;

var TKE = {

    sideTabModule: {
        
        options: {
            activeTabClass: 'active'
        },

        initialize: function(module_id) {

            if (V_DEBUG == true) {
                
                console.log("Initializing sideTabModule for " + module_id + "...");
                
            }
                

            // Get all direct-child headings.
            headings = $('#' + module_id + ' > h1, ' +
                '#' + module_id + ' > h2, ' +
                '#' + module_id + ' > h3, ' +
                '#' + module_id + ' > h4, ' +
                '#' + module_id + ' > h5, ' +
                '#' + module_id + ' > h6 ');

            // Get tab list.
            ul = $('#' + module_id + ' > ul');

            // Get the tabs.
            lis = ul.children();

            // Hide the headings.
            headings.css({
                display:'none'
            });

            // Display the tabs.
            ul.css({
                display:'block'
            });
            
            // Bind click events to tabs.
            lis.bind('click', function(e) {
                var section_id;
                
                // Get the section-id from the tab's dataset tag. First check
                // for HTML 5 dataset support, then failover to getAttribute.
                if (e.target.dataset != undefined) {
                    section_id = e.target.dataset.sectionId;
                } else {
                    section_id = e.target.getAttribute('data-section-id');
                }
                
                TKE.sideTabModule.switchTab(module_id, section_id, e.target); 
            });
            
            // Display the first section.
            lis.first().click();
            
            // Classify first tab to active.
            lis.first().addClass(this.options.activeTabClass);

        },

        switchTab: function(module_id, section_id, target) {

            if (V_DEBUG == true) {
                
                console.log("Executing showSAAGTab() for #" + section_id + "...");
                
            }
                
            // Get all jQuery objects.
            sections    = $('#' + module_id + ' section');
            section     = $('#' + section_id);
            tabs        = $(target).siblings();
            tab         = $(target);

            // Fade out all sections.
            sections.fadeOut();

            // Remove active-tab styling from all tabs.
            tabs.removeClass(this.options.activeTabClass);

            // Add active-tab styling to newly selected tab.
            tab.addClass(this.options.activeTabClass);
            
            // Fade in selected section.
            section.fadeIn();

            if (V_DEBUG == true) console.log("showSAAGTab() Complete.");
        }

    }, // End sideTabModule
    
    banner: {
        options: {
            rotateTime: 8000,
            fadeTime: 500
        },
        
        banners: {},
        
        activeBanner: 0,
        
        bannerTimer: '',
        
        initialize: function() {
            // Get all banner sections.
            this.banners = $('.banner');
           
            // Hide all banners.
            this.banners.css({'display': 'none'});
            //this.banners.children().css({'display': 'none'});
            
            // Create buttons.
            this.createButtons();
            
            // Click a random banner's button to start rotation.
            setTimeout(function() {
                
                //var rand = Math.floor(Math.random() * TKE.banner.banners.length );
                
                // Uncomment for random banner rotation.
                //$('.banner-button').eq(rand).click();
                
                $('.banner-button').eq(0).click();
                
            }, 300);
        },
        
        createButtons: function() {
            // Get banners container.
            var banners_container = $('.banners');
            
            // Create the banner button container.
            banners_container.append("<div id=\"banner-buttons\"></div>");
            
            // For each banner, add a button.
            var button_container = $('#banner-buttons');
            
            for( var i = 0; i < this.banners.length; i++ ) {
                button_container.append("<div data-banner=\"" + 
                    i + "\" class=\"banner-button\"></div>");
            }
            
            // Bind event listeners to newly created buttons.
            var btns = $('.banner-button');
       
            btns.bind('click', function(e) {
                var banner_no;
                
                // Get the banner number from the dataset tag. First check
                // for HTML 5 dataset support, then failover to getAttribute.
                if (e.target.dataset != undefined) {
                    banner_no = e.target.dataset.banner;
                } else {
                    banner_no = e.target.getAttribute('data-banner');
                }
                
                TKE.banner.changeBanner(banner_no);
            }); 
        },
        
        changeBanner: function(banner_no) {
            
            // Clear the rotation timer if user clicks button.
            clearTimeout(this.bannerTimer);
          
            this.animateOut();
          
            // Keep track of active banner, and reset count if the count
            // exceeds the number of banners. Used for automatic rotation.
            if( this.activeBanner < this.banners.length - 1 ) {
                this.activeBanner += 1;
            } else {
                this.activeBanner = 0;
            }
            
            // If called for automatic rotation, set the banner var to 
            // the next banner. If it was called by a user button push, then
            // set the active banner to the user selected button.
            if(banner_no == undefined) {
                
                banner_no = this.activeBanner;
            
            } else {
                
                // Typecast dataset value pulled from element.
                banner_no = Number(banner_no);
                
                this.activeBanner = banner_no;
            }
            
            this.animateIn(banner_no);
            
            // Clear button classes and set active class to current banner's 
            // button.
            $('#banner-buttons').children().removeClass('active');
            $('#banner-buttons').children().eq(banner_no).addClass('active');
            
            // Set a new timer for automatic rotation.
            this.bannerTimer = setTimeout(function() {
                TKE.banner.changeBanner();
            }, this.options.rotateTime);
        },
        
        animateIn: function(banner_no) {
            // Fade in banner, and animate the image and contents.
            $(this.banners[banner_no]).delay(this.options.fadeTime - 500).fadeIn();
            
            $(this.banners[banner_no]).delay(this.options.fadeTime).children('.banner-image').fadeIn('slow');
            
            $(this.banners[banner_no]).delay(this.options.fadeTime).children('.banner-content')
            .css({
                'top':'-200px',
                'opacity':'0'
            });
            
            $(this.banners[banner_no]).children('.banner-content').delay(this.options.fadeTime)
            .animate({
                'top':'0px', 
                'opacity': '1'
            });
        },
        
        animateOut: function(banner) {
            
            $(this.banners[this.activeBanner]).fadeOut(this.options.fadeTime-200);
            
        }
    }, // End banner
    
    flickrPhotoStreamer: {
        
        options: {
            nsid: '69026523@N03',
            div: 'photos',
            num: '15',
            thumbClass: 'flickrThumb'
        },
        
        photosArray: [],
       
        initialize: function() {
            var request;
            var requestURL = '/_/php/flickr_photostreamer.php?nsid=' + 
                this.options.nsid + '&num=' + this.options.num;
            var response;
	
            if (window.XMLHttpRequest) {		//Check for XMLHttpRequest Support
                request = new XMLHttpRequest();
            } else {					//No support for XMLHttpRequest (IE < 7)
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
	
            request.open('GET', requestURL, true);
	
            request.onreadystatechange = function () {
                if (request.readyState == 4) {
                    if (request.status == 200) {	
                        response = request.responseXML;
                        TKE.flickrPhotoStreamer.processXML(response);
                    } else {
                        //alert ('There was an error loading ' + requestURL + '.');
                    }
                }
            };
	
            request.send(null);
        },
        
        processXML: function(xml) {
            var photos = xml.getElementsByTagName('photo');
            var photo;
            var i;
	
            for (i = 0; i < photos.length; i++) {
                photo = new Object();
                photo.id = photos[i].getAttribute('id');
                photo.title = photos[i].getAttribute('title');
                photo.url_s = photos[i].getAttribute('url_s');
                photo.url_sq = photos[i].getAttribute('url_sq');
                photo.url_l = photos[i].getAttribute('url_l');
		
                this.photosArray.push(photo);
            }
	
            this.printHTML();
        },

        printHTML: function() {
            var d = document.getElementById(this.options.div);
            var i, src, title, alt;
		
            for(i = 0; i < this.photosArray.length; i++) {
                linkUrl = "http://www.flickr.com/photos/" + this.options.nsid + "/" + this.photosArray[i].id;
                src = this.photosArray[i].url_sq;
                alt = this.photosArray[i].title;
                title = this.photosArray[i].title;
		
                d.innerHTML += "<a href=\"" + linkUrl + "\" target=\"_blank\"><img class=\"" + this.options.thumbClass + "\" src=\"" + src + "\" alt=\"" + alt + "\" title=\"" + title + "\"/></a>";
            }
        }
        
    }, // End flickrPhotoStreamer
    
    circles: {
        initialize: function() {
            header = $('header .container');
            footer = $('footer .container');
            
            header_circle2 = "<div class=\"circle\" id=\"header_circle2\"><img class=\"png_fix\" src=\"/images/circle-2.png\"/></div>";
            header_circle3 = "<div class=\"circle\" id=\"header_circle3\"><img class=\"png_fix\" src=\"/images/circle-3.png\"/></div>";
            header_circle4 = "<div class=\"circle\" id=\"header_circle4\"><img class=\"png_fix\" src=\"/images/circle-4.png\"/></div>";
            header_circle5 = "<div class=\"circle\" id=\"header_circle5\"><img class=\"png_fix\" src=\"/images/circle-4.png\"/></div>";
            
            footer_circle1 = "<div class=\"circle\" id=\"footer_circle1\"><img class=\"png_fix\" src=\"/images/circle-3.png\"/></div>";
            footer_circle2 = "<div class=\"circle\" id=\"footer_circle2\"><img class=\"png_fix\" src=\"/images/circle-5.png\"/></div>";
            
            header.append(header_circle2);
            header.append(header_circle3);
            header.append(header_circle4);
            header.append(header_circle5);
            
            footer.append(footer_circle1);
            footer.append(footer_circle2);
        },
        
        animHomepageCircles: function(pause) {
            
            /* Get the circle jQuery objects. */
            circle2 = $('#header_circle2');
            circle3 = $('#header_circle3');
            circle4 = $('#header_circle4');
            circle5 = $('#header_circle5');
            
            if($('html').hasClass('ie8') || $('html').hasClass('ie7')) {
                
                circle3.css({
                    top:'-10px', 
                    left:'-80px'
                });
                
                circle4.css({
                    top:'120px', 
                    left:'330px'
                });
                
                circle2.css({
                    top:'80px', 
                    left:'-130px'
                });
                
                circle5.css({
                    top:'80px', 
                    left:'90px'
                });
                
            } else {
                
                /* Set initial CSS values for circles */
                circle2.css({
                    top:'180px', 
                    left:'-130px', 
                    opacity:'0'
                });
                circle3.css({
                    top:'100px', 
                    left:'-80px', 
                    opacity:'0'
                });
                circle4.css({
                    top:'300px', 
                    left:'330px', 
                    opacity:'0'
                });
                circle5.css({
                    top:'180px', 
                    left:'90px', 
                    opacity:'0'
                });
                
                /* Animate circles into positions after designated pause. */
                setTimeout(function() {
                
                    circle3.animate({
                        top:'-10px', 
                        left:'-80px',
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                    
                    circle4.delay(1500).animate({
                        top:'120px', 
                        left:'330px',
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                    circle2.delay(3000).animate({
                        top:'80px', 
                        left:'-130px',
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                    
                    circle5.delay(4500).animate({
                        top:'80px', 
                        left:'90px',
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                }, pause);
                
            }
            
        },
        
        animServicesCircles: function(pause) {
            
            /* Get the circle jQuery objects. */
            circle2 = $('#header_circle2');
            circle3 = $('#header_circle3');
            circle4 = $('#header_circle4');
            circle5 = $('#header_circle5');
            
            if($('html').hasClass('ie8') || $('html').hasClass('ie7')) {
                
                circle3.css({
                    top:'-10px', 
                    left:'-80px'
                });
                
                circle4.css({
                    top:'500px', 
                    left:'370px'
                });
                
                circle2.css({
                    top:'80px', 
                    left:'-130px'
                });
                
                circle5.css({
                    top:'80px', 
                    left:'90px'
                });
                
            } else {
                
                /* Set initial CSS values for circles */
                circle2.css({
                    top:'180px', 
                    left:'-130px', 
                    opacity:'0'
                });
            
                circle3.css({
                    top:'100px', 
                    left:'-80px', 
                    opacity:'0'
                });
            
                circle4.css({
                    top:'700px', 
                    left:'370px', 
                    opacity:'0'
                });
            
                circle5.css({
                    top:'180px', 
                    left:'90px', 
                    opacity:'0'
                });
            
                /* Animate circles into positions after designated pause. */
                setTimeout(function() {
                
                    circle3.animate({
                        top:'-10px', 
                        left:'-80px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                    circle4.delay(1500).animate({
                        top:'500px', 
                        left:'370px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                    circle2.delay(3000).animate({
                        top:'80px', 
                        left:'-130px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                    circle5.delay(4500).animate({
                        top:'80px', 
                        left:'90px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                }, pause);
                
            }
            
            
        }, 
        
        animServiceCircles: function(pause) {
            
            /* Get the circle jQuery objects. */
            circle2 = $('#header_circle2');
            circle3 = $('#header_circle3');
            circle4 = $('#header_circle4');
            circle5 = $('#header_circle5');
            
            if($('html').hasClass('ie8') || $('html').hasClass('ie7')) {
                
                circle3.css({
                    top:'-10px', 
                    left:'-80px'
                });
                circle4.css({
                    top:'120px', 
                    left:'330px'
                });
                
                circle2.css({
                    top:'80px', 
                    left:'-130px'
                });
                circle5.css({
                    top:'80px', 
                    left:'90px'
                });
                
            } else {
                
                /* Set initial CSS values for circles */
                circle2.css({
                    top:'180px', 
                    left:'-130px', 
                    opacity:'0'
                });
                circle3.css({
                    top:'100px', 
                    left:'-80px', 
                    opacity:'0'
                });
                circle4.css({
                    top:'300px', 
                    left:'330px', 
                    opacity:'0'
                });
                circle5.css({
                    top:'180px', 
                    left:'90px', 
                    opacity:'0'
                });
            
                /* Animate circles into positions after designated pause. */
                setTimeout(function() {
                
                    circle3.animate({
                        top:'-10px', 
                        left:'-80px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                    circle4.delay(1500).animate({
                        top:'120px', 
                        left:'330px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                    circle2.delay(3000).animate({
                        top:'80px', 
                        left:'-130px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                    circle5.delay(4500).animate({
                        top:'80px', 
                        left:'90px', 
                        opacity:'1'
                    }, 5000, 'easeOutExpo');
                
                }, pause);
                
            }
            
        }
    }, // End circles
    
    rotatingImages: {
        
        initialize: function(rotateTime) {
            
            images = $('.rotating-images img');
            
            images.css({opacity:'0'});
            
            // Start with last image, to remove flicker at start.
            var i = images.length - 1;
            
            $(images[i]).css({opacity:'1'});
            
            setInterval(function() {
                
                if(i < images.length - 1) {
                    
                    prev = i;
                    
                    i += 1;
                    
                    next = i;
                    
                } else {
                    
                    i = 0;
                    
                    next = i;
                    
                    prev = images.length - 1;
                    
                }
                
                $(images[prev]).animate({opacity:'0'}, 1000);
                $(images[next]).animate({opacity:'1'}, 1000);
                
            }, rotateTime);
            
        }
        
    }, // End rotatingImages
    
    mail: {
        
        initialize: function() {
            var defBorderColor, defBGColor;
            var errorBorderColor = '#C1292E';
            var errorBGColor = '#FFF2F3';
            
            var defName, defPhoneNumber, defMessage, defEmail;
            
            $('#footerFormName').bind('blur', validateName);
            $('#footerFormPhone').bind('blur', validatePhone);
            $('#footerFormEmail').bind('blur', validateEmail);
            $('#footerFormMessage').bind('blur', validateMessage);
            
	
            $('#footerFormName').bind('focus', defColors);
            $('#footerFormPhone').bind('focus', defColors);
            $('#footerFormEmail').bind('focus', defColors);
            $('#footerFormMessage').bind('focus', defColors);
            
            // Add the button for JS.
            $('#footerForm').append("<a id=\"footerFormSubmit\" class=\"button\">send</a>");
            
            $('#footerFormSubmit').bind('click', validateAndSendEmail);
            
            // Remove the submit button for non-JS capable browsers.
            $('#footerFormSubmit_NoJS').remove();
            
            // Get default values.
            defName = $('#footerFormName').val();
            defPhoneNumber = $('#footerFormPhone').val();
            defMessage = $('#footerFormMessage').val();
            defEmail = $('#footerFormEmail').val();
            
            function defColors(e) {
                if (e.currentTarget) {
                    e = e.currentTarget;
                }

                if(!defBorderColor && !defBGColor) {
                    defBorderColor = $(e).css('border-top-color');
                    defBGColor = $(e).css('background-color');
                }
	
                // Clear the default values
                if(e.id == 'footerFormName' && e.value == defName) 
                    e.value = '';
	
                if(e.id == 'footerFormPhone' && e.value == defPhoneNumber) 
                    e.value = '';
	
                if(e.id == 'footerFormEmail' && e.value == defEmail) 
                    e.value = '';
	
                if(e.id == 'footerFormMessage' && e.value == defMessage) 
                    e.value = '';
	
                e.style.borderColor = defBorderColor;	
                e.style.backgroundColor = defBGColor;
            }
            
            function validateName(e) {
	
                if (e.currentTarget) {
                    e = e.currentTarget;
                }
	
                if(!defBorderColor && !defBGColor) {
                    defBorderColor = $(e).css('border-top-color');
                    defBGColor = $(e).css('background-color');
                }
	
                var regex = /^['&,\.a-zA-Z\d\s]+$/;
                if (e.value == '' || e.value == defName) {
                    e.style.borderColor = errorBorderColor;	
                    e.style.backgroundColor = errorBGColor;
		
                    e.value = defName;
		
                    return false;
                } else {
                    if (e.value.match(regex)) {
                        e.style.borderColor = defBorderColor;	
                        e.style.backgroundColor = defBGColor;
                        return true;	
                    } else {
                        e.style.borderColor = errorBorderColor;	
                        e.style.backgroundColor = errorBGColor;
                        return false;
                    }
                }
            }

            function validatePhone(e) {
                var regex = /^1?[\.\s\-]?\(?[\d]{3}\)?[\.\s\-]?[\d]{3}[\.\s\-]?[\d]{4}$/;
	
                if(!defBorderColor && !defBGColor) {
                    defBorderColor = $(e.currentTarget).css('border-top-color');
                    defBGColor = $(e.currentTarget).css('background-color');
                }
	
                if (e.currentTarget) {
                    e = e.currentTarget;
                }
	
                if (e.value == '' || e.value == defPhoneNumber) {
                    e.style.borderColor = errorBorderColor;	
                    e.style.backgroundColor = errorBGColor;
		
                    e.value = defPhoneNumber;
		
                    return false;
                } else {
                    if (e.value.match(regex)) {
			
                        var num = e.value;
			
                        num = num.replace(/[\-|\.|\(|\)|\s]/ig, '');
                        num = num.slice(num.length - 10, 11);
                        //123 456 7890
                        //619 756 1954
                        num = '(' + num.substr(0,3) + ') ' + num.substr(3,3) + '-' + num.substr(6,4);
			
                        e.value = num;
			
                        e.style.borderColor = defBorderColor;	
                        e.style.backgroundColor = defBGColor;
			
                        return true;	
                    } else {
                        e.style.borderColor = errorBorderColor;	
                        e.style.backgroundColor = errorBGColor;
                        return false;
                    }
                }
            }

            function validateEmail(e) {
                var regex = /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
	
                if (e.currentTarget) {
                    e = e.currentTarget;
                }
	
                if(!defBorderColor && !defBGColor) {
                    defBorderColor = $(e).css('border-top-color');
                    defBGColor = $(e).css('background-color');
                }
	
	
                if (e.value == '' || e.value == defEmail) {
                    e.style.borderColor = errorBorderColor;	
                    e.style.backgroundColor = errorBGColor;
		
                    e.value = defEmail;
		
                    return false;
                } else {
                    if (e.value.match(regex)) {
                        e.style.borderColor = defBorderColor;	
                        e.style.backgroundColor = defBGColor;
                        return true;
                    } else {
                        e.style.borderColor = errorBorderColor;	
                        e.style.backgroundColor = errorBGColor;
                        return false;
                    }
                }
            }

            function validateMessage(e) {
                var regex = /^[\s\w\.\-\?,\(\)\$\*!:;`~@#%\^&=+"']+$/;
	
                if (e.currentTarget) {
                    e = e.currentTarget;
                }
	
                if(!defBorderColor && !defBGColor) {
                    defBorderColor = $(e).css('border-top-color');
                    defBGColor = $(e).css('background-color');
                }
	
	
	
                if (e.value == '' || e.value == defMessage) {
                    e.style.borderColor = errorBorderColor;	
                    e.style.backgroundColor = errorBGColor;
				
                    e.value = defMessage;
		
                    return false;
                } else {
                    if (e.value.match(regex)) {
                        e.style.borderColor = defBorderColor;	
                        e.style.backgroundColor = defBGColor;
                        return true;
                    } else {
                        e.style.borderColor = errorBorderColor;	
                        e.style.backgroundColor = errorBGColor;
                        return false;
                    }
                }
            }
            
            function validateAndSendEmail() {
                var name = document.getElementById('footerFormName');
                var phone = document.getElementById('footerFormPhone');
                var email = document.getElementById('footerFormEmail');
                var message = document.getElementById('footerFormMessage');
	
                var validName = validateName(name);
                var validPhone = validatePhone(phone);
                var validEmail = validateEmail(email);
                var validMessage = validateMessage(message);
	
                if(validName && validPhone && validEmail && validMessage) {
                    sendEmail(name.value, phone.value, email.value, message.value);
		
                    blackout();
                    sendingEmailMessage();
		
                    setTimeout( function() {
                        clearBlackout();
                        document.getElementById('footerForm').reset();
                    }, 2000);
                } 
            }

            function sendEmail(name, phone, email, message) {
                var request;
                var requestURL = '/_/php/mail.php?name=' + name + '&phone=' + phone + '&email=' + email + '&message=' + message;
                var response;
	
                if (window.XMLHttpRequest) {				//Check for XMLHttpRequest Support
                    request = new XMLHttpRequest();
                } else {									//No support for XMLHttpRequest (IE < 7)
                    request = new ActiveXObject('Microsoft.XMLHTTP');
                }
	
                request.open('GET', requestURL, true);
	
                request.onreadystatechange = function () {
                    if (request.readyState == 4) {
                        if (request.status == 200) {	
                            response = request.responseXML;
                        } else {
                    alert ('There was an error loading ' + requestURL + '.');
                    }
                    }
                };
	
                request.send(null);
            }
            
            function sendingEmailMessage() {
                $('<div id=\"sendingEmail\"><img src=\"/images/wait.gif\"/><h3>sending...</h3></div>').appendTo('body');
	
                var div = $('#sendingEmail');
                var h3 = $('#sendingEmail h3');
                var img = $('#sendingEmail img');
                var f = $('#email');
	
                div.css({ 
                    "top":"0px", 
                    "left":"0px",
                    "background-color":"#000",
                    "opacity":"0",
                    "z-index":"103",
                    "position":"fixed",
                    "text-align":"center",
                    "border-radius":"20px",
                    "height":"140px",
                    "width":"200px"
                });
	
                img.css({
                    "margin":"25px auto 0px auto",
                    "border":"none",
                    "float":"none"
                });
	
                h3.css({
                    "color":"white",
                    "font-size":"1.5em",
                    "padding-top":"15px",
                    "position":"absolute",
                    "bottom":"30px",
                    "text-align":"center",
                    "width":"100%",
                    "padding-left":"5px",
                    "margin-bottom":"0px"
                });
	
                var x = ($(window).width()/2) - (div.width()/2);
                var y = ($(window).height()/2) - (div.height()/2);
	
                div.css('top',y);
                div.css('left',x);
	
                f.fadeTo(1000, 0.9);
                div.fadeTo(1000, 0.9);
	
                setTimeout( function(){
                    $('#sendingEmail img').fadeTo(400, 0);
                    div.animate({
                        height: 80
                    },1000, 'easeOutCubic');
                    h3.css({
                        "padding-left":"0px"
                    });
                    h3.text('message sent!');
		
                    setTimeout(function() {
                        div.fadeTo(1000, 0);
                        f.fadeTo(1000, 1);
                        setTimeout( function() {
                            div.remove();
                        },1000);
                    },3000);
		
                },2000);
	
                return div;
            }
            
            //Pass functional arguments, or not and use the constant definitions.
            function blackout(div_id, fade_speed) {
                //-------------------------------------------------
                // Constant Definitions
                //-------------------------------------------------
                var DIV_ID = "blackout";		//Default DIV ID.
                var FADE_SPEED = 1000;			//Fade speed in miliseconds.
                var COLOR = "#000";				//DIV background color.
                var ZINDEX = "100";				//Z-Index of DIV.
                var OPACITY = 0.7;				//Ending opacity.
	
                //-------------------------------------------------
                // Constant Definitions
                //-------------------------------------------------
	
                var id = (typeof div_id == "undefined") ? DIV_ID : div_id;
                var spd = (typeof fade_speed == "undefined") ? FADE_SPEED : fade_speed;
	
                //Create the DIV and add to BODY.
                $('<div id='+ id + '></div').appendTo('body');
                var div = $('#' + id);
	
                //Apply CSS styles.
                div.css({
                    "position":"absolute", 
                    "top":"0px", 
                    "left":"0px",
                    "background-color":COLOR,
                    "opacity":"0",
                    "z-index":ZINDEX,
                    "height":$(document).height() + 'px',
                    "width":$(document).width() + 'px'
                });
	
                //Fade-in DIV.
                div.fadeTo(spd, OPACITY);
	
                //Listen for window resize, and resize curtain accordingly.
                $(window).bind('resize', function() {
                    div.css('width', '0px');
                    div.css('width', $(document).width() + 'px');
                });
	
                //Returns reference to jQuery DIV object.
                return div;
            }

            function clearBlackout() {
                var div = $('#blackout');
                div.fadeTo(1000, 0);
                setTimeout(function() {
                    div.remove();
                }, 1000);
            }
        }
        
    }, // End Email
    
    scrollToBottom: function scrollToEmailForm() {	
	$('html, body').delay(50).animate({
            scrollTop:($(document).height()-$(window).height())},
            $(document).height(),
            'easeOutExpo');
            
        setTimeout(function(){
            document.getElementById("footerFormName").focus();
        },1500);
        
    }, // End scrollToBottom
    
    didYouKnow: {
        
        initialize: function() {
        
            var dyk = $('.did-you-know');
        
            dyk.css({'display':'none'});
            
            var rand = Math.floor(Math.random() * dyk.length );
            
            $(dyk[rand]).css({'display':'block'});
        
        }
        
    } // End didYouKnow
    
};
