$(document).ready( function() {
    var textArray = [
        '<p>Our son is a resident at the P.J. Spastic Center. When he came down with a serious case of Chicken Pox, we were informed to take him out of home until he recovers so as not to infect the other children. His doctor instructed that he will be admitted to hospital for treatment (intravenous antibiotics). With <strong>Nurses At Home</strong>, my husband and I were able to continue working while my family members looked after my son, supported by the nurses. My son responded well to the nurse who was well trained in communicating with children. The availability of this service helped us through a difficult time!<br/><strong>Mdm. Chang - Mother of LW, 7</strong></p>',
        '<p><strong>Nurses At Home</strong> is a great service. It was convenient, the timing was flexible and the nurses were just as good if not better than any other nurses I have seen before at hospitals. I was able to continue running my eatery as all I needed to do was to stop work for a short time when the nurse arrived. Even better was the fact that all my charges were covered by my Prudential insurance policy.<br/><strong>Mr. Mah, 47</strong><br/><strong>Eatery Operator</strong></p>',
        '<p>I have had occasion to waited 3 hours to get my mother attended to and considering that Mum requires dressings twice a week for her diabetic foot ulcer, I am just happy that <strong>Nurses At Home</strong> is around. It was also impossible to move Mum from house to hospital on my own without relatives to help on.<br/><strong>Datin Rozana Ramli, 60</strong><br/><strong>Retired Teacher</strong></p>',
        '<p>I have always disliked hospitals. Unfortunately, I found myself in one due to rheumatoid arthritis. I found the hospital environment very intimidating and the food was tasteless. When I found out about <strong>Nurses At Home</strong> I checked with my doctor whether it would be alright to be discharged. I loved the service as they allowed me to go home to recover in my very comfortable home. To top it off, their nurses were also very responsible and punctual. I would recommend this service to anyone!<br/><strong>Mdm. Ang, 54</strong><br/><strong>Housewife</strong></p>',
        '<p>Yes very satisfied indeed. I could call anytime with any problem whatsoever and it was taken care of very promptly and professionally<br/><strong>Ms Pereira</strong><br/><strong>Subang Jaya</strong><br/><br/>The carer that came to take care of my mom was very caring thoughtful and diligent person. My mom was very comfortable being around her.<br/><strong>Ms Marimuthu</strong><br/><strong>Kuala Lumpur</strong></p>',
        '<p>Nurse came despite her tight schedule. Nurse informed I can call her anytime for assistance. Nurse is passionate about her job and is very caring and patient.<br/><strong>Cik Faridah</strong><br/><strong>Gombak</strong><br/><br/>The nurses are gentle and reliable to my mother - their patient.<br/><strong>Puan Noorkiah</strong><br/><strong>Ampang Jaya</strong></p>',
        '<p>Nurse F has genuine concern of the patient at heart. She works with compassion and dedication. Gentle at all times and shares information.<br/><strong>Christine</strong><br/><strong>Puncak Nusa Kelana</strong><br/><br/>Nurse S is competent, confident, reassuring, cheerful, warm and friendly. I feel I that I am in good hands.<br/><strong>Mr Gan</strong><br/><strong>Subang Jaya</strong></p>',

    ];
    $('#text-content').loadText( textArray, 8000 ); // ( array, interval )
});
// custom jquery plugin loadText()
$.fn.loadText = function( textArray, interval ) {
    return this.each( function() {
        var obj = $(this);
        obj.fadeOut( 'slow', function() {
            obj.empty().html( random_array( textArray ) );
            obj.fadeIn( 'slow' );
        });
        timeOut = setTimeout( function(){ obj.loadText( textArray, interval )}, interval );
        // reload random text (if not animated) -- entirely optional, can be removed, along with the reload link above (<a href="javascript:;" id="text-reload"><em>randomize</em></a>)
        $("#text-reload").click( function(){
            if( !obj.is(':animated') ) { clearTimeout( timeOut ); obj.loadText( textArray, interval );} // animation check prevents "too much recursion" error in jQuery
        });
    });
}
//public function
function random_array( aArray ) {
    var rand = Math.floor( Math.random() * aArray.length + aArray.length );
    var randArray = aArray[ rand - aArray.length ];
    return randArray;
}
