﻿// The Cuepoints
var bobbyCues = [0,5500,15000];
var bobbyFunction = function(clip, point){
    if(point == 0){showWords("Bobby Clarkson<br />Founder")};
    if(point == 5500){showWords("Please take some time to<br />meet our customers")};
    if(point == 15000){showWords("Click a tab below<br /> to hear their stories")};
}

var randyCues = [0,6000,8000,13000,17000,19000];
var randyFunction = function(clip, point){
    if(point == 0){showWords("Randy Coe<br />President of Kosair Charities")};
    if(point == 6000){showWords("We care for thousands<br /> of children every year")};
    if(point == 8000){showWords("Clarkson Insurance helps us accomplish this")};
    if(point == 13000){showWords("They help with Property and Casualty Insurance")};
    if(point == 17000){showWords("They train and educate our staff")};
    if(point == 19000){showWords("They're just what we needed")};
}

var kentCues = [0,7000,12000,18000];
var kentFunction = function(clip, point){
    if(point == 0){showWords("Kent Taylor<br />Founder of Texas Roadhouse")};
    if(point == 7000){showWords("Insured my farm, houses, and cars")};
    if(point == 12000){showWords("They helped us through two accidents")};
    if(point == 18000){showWords("Will do business with them for many years to come")};
}

var alCues = [0,5000,9000,14000,21000,33000,42000,45000];
var alFunction = function(clip, point){
    if(point == 0){showWords("Al Sullivan, Chancellor and Founder of Sullivan University")};
    if(point == 5000){showWords("We have over 9,000 students and 1,200 employees")};
    if(point == 9000){showWords("We have a need for a variety of insurance solutions")};
    if(point == 14000){showWords("For well over 30 years, we have worked with Clarkson Insurance")};
    if(point == 21000){showWords("They seek out competitive prices, with great insurance benefits")};
    if(point == 33000){showWords("No one else will work harder to provide the service you need")};
    if(point == 42000){showWords("We trust Clarkson, you will too")};
    if(point == 45000){showWords("I highly recommend them for your insurance needs")};
}


// Preloading Backgrounds

backRandy= new Image(930,300); 
backRandy.src="http://www.rhcgroup.com/App_Themes/RHC/images/randy_background.jpg";
backKent= new Image(930,300); 
backKent.src="http://www.rhcgroup.com/App_Themes/RHC/images/kent_background.jpg";
backAl= new Image(930,300); 
backAl.src="http://www.rhcgroup.com/App_Themes/RHC/images/al_background.jpg";

function startFlow(theClip, theCues, theFunction) {
    flowplayer("skinless", { src: "videos/flowplayer.commercial-3.2.5.swf", wmode: 'transparent'}, {
        clip: {
            url: theClip,
            onCuepoint: [theCues, theFunction]
        },        
        plugins: {
            tube: {
                url: "http://releases.flowplayer.org/swf/buttons_tube.swf",
                type: "classLibrary"
            },
            controls: null
        },
        canvas: {
            backgroundGradient: 'none',
            background: 'transparent'
        },
        key: '#$2a82c2c973433bd8289'
    });
}

switchFinished = false;

function switchMovie(person) {
    
    if(switchFinished == true){
    
        switchFinished = false;
        showWords("&nbsp;")
        setTimeout("$('#wording').css('left','400px')", 1000);
        jQuery('#skinless').fadeOut(1, function() {
            jQuery('#skinless').show();
            
            if(person == "bobby"){        
                jQuery('#skinless').css("width", "256px");
                jQuery('#wording').css("color", "black");
                startFlow("http://www.rhcgroup.com/videos/BobbyPopOut.flv", bobbyCues, bobbyFunction);
                showBackground('bobby');
            }
            else if(person == "al"){
                jQuery('#skinless').css("width", "304px");
                jQuery('#wording').css("color", "white");
                startFlow("http://www.rhcgroup.com/videos/SullivanPopOut.flv", alCues, alFunction);
                showBackground('al');
            }
            else if(person == "randy"){
                jQuery('#skinless').css("width", "256px");
                jQuery('#wording').css("color", "white");
                startFlow("http://www.rhcgroup.com/videos/RandyPopOut.flv", randyCues, randyFunction);
                showBackground('randy');
            }
            else if(person == "kent"){
                jQuery('#skinless').css("width", "352px");
                jQuery('#wording').css("color", "white");
                startFlow("http://www.rhcgroup.com/videos/KentPopOut.flv", kentCues, kentFunction);
                showBackground('kent');
            }
            
            $f().play();
        });
    
    }
    
}

function showBackground(person){
       
    //new background on top
    $('#bobby').css("z-index","1");
    $('#al').css("z-index","1");
    $('#randy').css("z-index","1");
    $('#kent').css("z-index","1");
    $('#' + person).css("z-index", "2");

    //fade in new background
    $("#" + person).fadeIn(1000, function(){
        
        hideOtherBackgrounds(person);
        switchFinished = true;
    
    });
}

function hideOtherBackgrounds(person){
    if(person == "bobby"){
        $('#al').css("display","none");
        $('#randy').css("display","none");
        $('#kent').css("display","none");
    }
    else if(person == "al"){
        $('#bobby').css("display","none");
        $('#randy').css("display","none");
        $('#kent').css("display","none");
    }
    if(person == "randy"){
        $('#al').css("display","none");
        $('#bobby').css("display","none");
        $('#kent').css("display","none");
    }
    if(person == "kent"){
        $('#al').css("display","none");
        $('#randy').css("display","none");
        $('#bobby').css("display","none");
    }
}

function showWords(wording){
    $('#wording').animate({ top: '20px' }, {duration: 500, queue: false});
    $('#wording').fadeOut(500, function(){
        $('.wording').html(wording);
        $('#wording').fadeIn(500);
        $('#wording').animate({ top: '40px' }, {duration: 500, queue: false});
    });
}

jQuery(document).ready(function() {
       
    welcome = "Welcome to the<br /><span style='font-size:34px; color:#550F0F;'>RH Clarkson Insurance Group</span>";
    clickon = "Please click a tab below to<br /><span style='color:#550F0F; font-size:42px'>hear from our customers.</span>";
        
    $('#wording').css("left","200px");
    showWords(welcome);
    setTimeout("showWords(clickon)", 3000);
    setTimeout("finishStart()", 4000);
    
    
});

function finishStart(){
    
    $('.tab_randy').animate({ height: '50px' }, {duration: 1000});;
    setTimeout("$('.tab_kent').animate({ height: '50px' }, {duration: 1000});;", 300);
    setTimeout("$('.tab_al').animate({ height: '50px' }, {duration: 1000});;", 600);
    switchFinished = true;
    
}





