// JScript File


var playerConfig =             
			{  
              autoPlay: true,
              autoRewind: true,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              initialScale: 'scale',
              loop: false, 
              useNativeFullScreen: true
            }

var flowplayer = flashembed("playerContainer",
        {
          src:'FlowPlayerDark.swf',
          width:480, 
          height:360
        },
        {config: 
            {  
              autoPlay: true,
              autoRewind: true,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              initialScale: 'scale',
              loop: false, 
              useNativeFullScreen: true
            }
        } 
        );


  function showMyVideo(series)
{
    var vidFile= 'videos/' + series + '.flv';
    var imgFile = 'videos/' + series + '.jpg'
    var pList= [ {url: imgFile, duration: 10},	{url: vidFile}];
	
	if (series == "start")
	{
		pList = [{url: 'videos/lttf-ad.flv'}, {url: 'videos/start.flv'}]
	}
	
	if( series == "lttf") {
		
		pList = [{url: 'videos/lttf-trailer.flv'}];
	
	}
    
    var api = flashembed("playerContainer",
        {
          src:'FlowPlayerDark.swf',
          width:480, 
          height:360
        },
        {config: 
            {  
              autoPlay: true,
              autoRewind: false,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              splashImageFile: imgFile,
              playList: pList,
              initialScale: 'scale',
              loop: false, 
              useNativeFullScreen: true
            }
        } 
    );
  }
  function old_showMyVideo(series)
{
    var vidFile= 'videos/' + series + '.flv';
    var imgFile = 'videos/' + series + '.jpg'
    var pList= [ {url: imgFile, duration: 10},	{url: vidFile}];
    var api = flashembed("playerContainer",
        {
          src:'FlowPlayerDark.swf',
          width:480, 
          height:360
        },
        {config: 
            {  
              autoPlay: true,
              autoRewind: false,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              splashImageFile: imgFile,
              playList: pList,
              initialScale: 'scale',
              loop: false, 
              useNativeFullScreen: true
            }
        } 
    );
  }

function loopMyVideo(vidFile)
{
    $("#playerContainer").flashembed
    (
        {
          src:'FlowPlayerDark.swf',
          width:480, 
          height:360
        },
        {config: 
            {  
              autoPlay: true,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              videoFile: vidFile,
              initialScale: 'scale',
              loop: true, 
              useNativeFullScreen: true
            }
        } 
    );
  }

function changeMyVideo(vidFile)
{
    var player = $('#playerContainer')[0];
    // player.DoStop();
    // alert('Stopped?');
    player.setConfig(
            {  
              autoPlay: true,
              usePlayOverlay: false,
              noVideoClip: {url: 'Sorry.jpg', duration: 10},
              videoFile: vidFile,
              initialScale: 'scale',
              loop: false, 
              useNativeFullScreen: true
            }
        );
}
function showMaterial(series)
{
	var blurbUri = 'blurb/'+series + '_blurb.html';
	var topUri = 'blurb/'+series + '_top.html';
	var moreUri = 'blurb/'+series + '_more.html';
	var blurb = "";

	$('#leaders-menu').hide();
	$('#alive-menu').hide();
	$('#contact-info').hide();
	$('#retreat-info').hide();
	$("#dwc-info").hide();
	$('#moreText').hide();
	
	nowShowing = series;
	if (wideMode)
	{
		// Animate the panel back first
		$("#rightPanel").animate({left: narrowLeft, width: narrowWidth }, 1000,
		function() 
		{
			$('#playerContainer').show();
			$('#rightText').fadeIn(1000);
			wideMode = false;
			$('#moreLess').attr({value: "< More Info"});
			//$("#moreLess").show();
			showMyVideo(series);
		});
	}
	else
	{
			$('#playerContainer').show();
			$('#rightText').fadeIn(1000);
			showMyVideo(series);
	}
	// load text into boxes on right and top
	$('#rightText').empty();
	$('#rightText').load(blurbUri);
	$('#topText').empty();
	$('#topText').load(topUri);
	$('#moreText').hide();
	$("#moreLess").hide();
	$('#moreText').empty();
	var s = nowShowing.substring(0,3);
	// don't show buy now for alive in christ or the intro to cafe - they are not for sale
	if ((s == "aic")||(s=="int"))
	{
		$('#buyNow').hide();
	}
	else
	{
		$('#buyNow').show();
	}
	// load more text and if there is any, show the more text button.
	
	$('#moreText').load(moreUri,function(){
	$("#moreLess").show();
	});
}



var wideMode = false;  // true if player obscured by wide rightPanel
var wideLeft = "60px";
var wideWidth = "740px";
var narrowLeft = "540px";
var narrowWidth = "260px";
var nowShowing = "start";
var aicMode = false;	// true if doing AIC panel;

function showMore()
{
	$('#playerContainer').hide();
	$("#rightText").fadeOut(2000);
	$("#rightPanel").animate({left: wideLeft, width: wideWidth }, 1000,
	function() {
		$("#moreText").fadeIn(1000);
		if (nowShowing == "lic") {
			$("#dwc-info").fadeIn(1000);
			$("#dwc-info").show();
			}
	});	
	wideMode = true;
	$('#moreLess').attr({value: "> Less Info"});	
}
function showLess()
{
	$("#dwc-info").hide();
	$('#moreText').hide();
	$("#rightPanel").animate({left: narrowLeft, width: narrowWidth }, 1000,
		function() 
		{
			$('#playerContainer').fadeIn(1000);
			$('#rightText').fadeIn(2000);
		}
	);
	wideMode = false;
	$('#moreLess').attr({value: "< More Info"});
}
function showMoreLess()
{
	if (wideMode) showLess()
	else showMore();
}
function showLeaders()
{
	//alert('showLeaders');
	if (nowShowing == "leaders") return;
	var series = "leaders";
	nowShowing = series;
	$('#alive-menu').hide();
	$('#contact-info').hide();
	$('#retreat-info').hide();
	$("#dwc-info").hide();
	$("#moreLess").hide();
	$('#playerContainer').hide();	
	$('#topText').empty();
	$('#topText').load('blurb/'+series + '_top.html');
	$('#moreText').empty();
	$('#moreText').load('blurb/'+series + '_more.html');
	$("#rightText").fadeOut(2000);
	$("#rightPanel").animate({left: wideLeft, width: wideWidth }, 1000,	function() {
		$("#moreText").fadeIn(1000);
		$('#leaders-menu').show();
	});	
	wideMode = true;	
}
function showAlive()
{
	//togle the Alive in Christ button
	aicMode = !aicMode;
	if (aicMode)
	{
		$("#CaFE-Panel").hide();
		$("#AIC-Panel").show();
		
		$('#leaders-menu').hide();
		$('#contact-info').hide();
		$('#retreat-info').hide();
		$("#dwc-info").hide();
		//$("#moreLess").hide();
		//$("#buyNow").hide();
		$("#alive").attr({value: "Back to CaFE"});
	}
	if (!aicMode)
	{
		$("#CaFE-Panel").show();
		$("#AIC-Panel").hide();	
		$('#leaders-menu').hide();
		$('#contact-info').hide();
		$('#retreat-info').hide();
		$("#dwc-info").hide();
		//$("#moreLess").hide();
		//$("#buyNow").show();
		$("#alive").attr({value: "Alive in Christ"});

	}

}

function showContactInfo()
{
	if (nowShowing == "contact") return;
	var series = "contact";
	$('#leaders-menu').hide();
	$('#alive-menu').hide();
	$('#retreat-info').hide();
	nowShowing = series;
	$("#dwc-info").hide();
	$("#moreLess").hide();
	$('#playerContainer').hide();	
	$('#topText').empty();
	$('#moreText').empty();
	$("#rightText").fadeOut(2000);
	$('#contact-info').fadeIn(1000);
	// wideMode = true;	
}
function showRetreatInfo()
{
	if (nowShowing == "retreats") return;
	var series = "retreats";
	$('#leaders-menu').hide();
	$('#alive-menu').hide();
	$('#contact-info').hide();
	nowShowing = series;
	$("#dwc-info").hide();
	$("#moreLess").hide();
	$('#playerContainer').hide();	
	$('#topText').empty();
	$('#moreText').empty();
	$("#rightText").fadeOut(600, function() {
		$('#retreat-info').fadeIn(600);
	});
	
}

function home()
{
	showMaterial("start");	
}
function showLeft(info)
{
	var aID =  "#" + info;
	$('#moreText').hide();
	$('#topText').empty();
	$('#moreText').empty();
	$('#moreText').load('blurb/'+info + '.html');
	$('#moreText').fadeIn(1000);
	$('li a').removeClass('selected').addClass('notSelected');
	$(aID).removeClass('notSelected').addClass('selected');
}
function mouseIsOver(info)
{
	var aID =  "#" + info;
	$('li a').removeClass('mouseOver').addClass('mouseNotOver');
	$(aID).removeClass('mouseNotOver').addClass('mouseOver');
}
function mouseIsNotOver(info)
{
	$('li a').removeClass('mouseOver').addClass('mouseNotOver');
}

