var globalVaribleContent = 'contentHeroSection1', 
    globalVaribleButton = 'slideButton1', 
    globalVaribleHeroButton = 'ctaHero1', 
    globalVaribleAutoAnimate = 1, 
    autoAnimate1,
    autoAnimate2, 
    autoAnimate3,
    autoAnimate4;



function animationFadeIn(fadeContent) {
    contentFade = new OpacityTween(document.getElementById(fadeContent), Tween.regularEaseIn, 0,100, .7);
    contentFade.start();
}

function openSelectedContent(newContent, CTAbutton, button) {

    if (newContent != globalVaribleContent) {
        
        if (globalVaribleAutoAnimate == 1) {
            globalVaribleAutoAnimate = 0;
            
            document.getElementById(globalVaribleContent).style.visibility="hidden";
            document.getElementById(globalVaribleContent).style.opacity=0;
            document.getElementById(globalVaribleContent).style.filter="Alpha(opacity=0)";

            $("#"+globalVaribleContent).css("left", "-9999em");
    
            document.getElementById(newContent).style.visibility="visible";
            $("#"+newContent).css("left", "0%");
        
            document.getElementById(globalVaribleButton).style.opacity=.6;
            document.getElementById(globalVaribleButton).style.filter="Alpha(opacity=60)";
        
            document.getElementById(button).style.opacity=1;
            document.getElementById(button).style.filter="Alpha(opacity=100)";
        
            globalVaribleContent = newContent;
            globalVaribleButton = button;
        
            animationFadeIn(newContent);
        
        } else {
        
            document.getElementById(globalVaribleContent).style.visibility="hidden";
            $("#"+globalVaribleContent).css("left", "-9999em");
    
            document.getElementById(globalVaribleContent).style.opacity=0;
            document.getElementById(globalVaribleContent).style.filter="Alpha(opacity=0)";
    
            document.getElementById(newContent).style.visibility="visible";
            $("#"+newContent).css("left", "0%");
        
            document.getElementById(globalVaribleButton).style.opacity=.6;
            document.getElementById(globalVaribleButton).style.filter="Alpha(opacity=60)";
        
            document.getElementById(button).style.opacity=1;
            document.getElementById(button).style.filter="Alpha(opacity=100)";
        
            globalVaribleContent = newContent;
            globalVaribleButton = button;
            globalVaribleAutoAnimate = 1;
       
            animationFadeIn(newContent);
            animationFadeIn(CTAbutton);
        }
    } 
}

function autoAnimateContent(newContent, CTAbutton, button) {
    document.getElementById(globalVaribleContent).style.visibility="hidden";
//    document.getElementById(globalVaribleHeroButton).style.visibility="hidden";
    $("#"+globalVaribleContent).css("left", "-9999em");
    
    document.getElementById(globalVaribleContent).style.opacity=0;
    document.getElementById(globalVaribleContent).style.filter="Alpha(opacity=0)";
//    document.getElementById(globalVaribleHeroButton).style.opacity=0;
//    document.getElementById(globalVaribleHeroButton).style.filter="Alpha(opacity=0)";
    
    document.getElementById(newContent).style.visibility="visible";
//    document.getElementById(CTAbutton).style.visibility="visible";
    $("#"+newContent).css("left", "0%");
        
        
    document.getElementById(globalVaribleButton).style.opacity=.6;
    document.getElementById(globalVaribleButton).style.filter="Alpha(opacity=60)";
        
    document.getElementById(button).style.opacity=1;
    document.getElementById(button).style.filter="Alpha(opacity=100)";
        
    globalVaribleContent = newContent;
    globalVaribleButton = button;
//    globalVaribleHeroButton = CTAbutton;
        
    animationFadeIn(newContent);
    animationFadeIn(CTAbutton);
}


function autoStartAnimateTimer () {
    autoAnimate1 = setTimeout(autoAnimationPhase1, 8000);
}

function autoAnimatePhase2Timer () {
    autoAnimate2 = setTimeout(autoAnimationPhase2, 8000);
}

function autoAnimatePhase3Timer () {
    autoAnimate3 = setTimeout(autoAnimationPhase3, 8000);
}

function autoAnimatePhase4Timer () {
    autoAnimate4 = setTimeout(autoAnimationPhase4, 8000);
}



function autoAnimationPhase1 () {
    if (globalVaribleAutoAnimate == 0) {
        clearTimeout(autoAnimate1);
    } else {
        autoAnimateContent('contentHeroSection2', 'ctaHero2', 'slideButton2');
        autoAnimatePhase2Timer();
    }
}

function autoAnimationPhase2 () {
    if (globalVaribleAutoAnimate == 0) {
        clearTimeout(autoAnimate2);
    } else {
        autoAnimateContent('contentHeroSection3', 'ctaHero3', 'slideButton3');
        autoAnimatePhase3Timer();
    }
}

function autoAnimationPhase3 () {
    if (globalVaribleAutoAnimate == 0) {
        clearTimeout(autoAnimate3);
    } else {
        autoAnimateContent('contentHeroSection1', 'ctaHero1', 'slideButton1');
        autoStartAnimateTimer();            
    }
}

function autoAnimationPhase4 () {
    if (globalVaribleAutoAnimate == 0) {
        clearTimeout(autoAnimate4);
    } else {
        autoAnimateContent('contentHeroSection1', 'ctaHero1', 'slideButton1');
        autoStartAnimateTimer();
    }
}

function playLargeVideo (videoWholePage, stupidIframe, bgFrame) {

    $("#videoWholePage").show();
    $('#'+bgFrame).css("display", "block").animate({
        top: '-170px',
        height: '1000px'
    }, 500 ).animate({
        left: '-40px',
        width:'1060px'
    });
    $('#'+videoWholePage).removeClass('none').addClass('clearfix');
//        document.getElementById(videoWholePage).style.visibility="visible";
        $('#videoIframe').show();
    if (globalVaribleAutoAnimate == 1) {
        globalVaribleAutoAnimate = 0;
    }
}

function closeLargeVideo (videoWholePage, iframe, bgFrame) {
    $('#iframe').hide();
    $('#videoWholePage').hide();
    $('#'+bgFrame).hide();
    $('#'+bgFrame).css({
        width:	'10px',
	    height: '0px',
	    background: 'black', 
	    position: 'absolute', 
	    filter: 'Alpha(opacity=60)',
	    opacity: '.85',
	    left: '520px'
	});
	
	if (globalVaribleAutoAnimate == 0) {
        globalVaribleAutoAnimate = 1;
    }
    
    
}




