  var jpPath = "media/Videos/";
  var jpFile = "realworld.mp3";
  var jvOpen = false; // player visible
  var jpPriorFile = "";
  var vp;
  var vpPrior;
/*
 All Scripture quotations, unless otherwise indicated, are taken from The Holy Bible, English Standard Version. Copyright &copy;2001 by <a href="http://www.crosswaybibles.org">Crossway Bibles</a>, a publishing ministry of Good News Publishers. Used by permission. All rights reserved.
*/
	evt=Array(
    {"type":tHTML, "target":"#jw_info",
     "time":539,  "text": "<br><strong>Develop good habits</strong>"},
    {"time":543, "text": "<br><strong>Develop good habits</strong><br><br>Luke 2:39-40 (ESV) And when they had performed everything according to the Law of the Lord, they returned into Galilee, to their own town of Nazareth. 40  And the child grew and became strong, filled with wisdom. And the favor of God was upon him."},    
     {"time":605, "text": "<br><strong>Develop good habits</strong><br><br>Luke 2:41-42 (ESV) Now his parents went to Jerusalem every year at the Feast of the Passover. 42 And when he was twelve years old, they went up according to custom."},
     {"time":813, "text": "<br><strong>Develop good habits</strong><br><br>Luke 6:12 (ESV) In these days he went out to the mountain to pray, and all night he continued in prayer to God."},
     {"time":965, "text": "<br><strong>Develop good habits</strong><br><br>Psalm 37:3-5 (ESV) Trust in the LORD, and do good; dwell in the land and befriend faithfulness. 4  Delight yourself in the LORD, and he will give you the desires of your heart. 5  Commit your way to the LORD; trust in him, and he will act."},
    {"time":1099, "text": "<br><strong>Take risks</strong>"},
    {"time":1103, "text": "<br><strong>Take risks</strong><br><br>Luke 2:43-45 (ESV) And when the feast was ended, as they were returning, the boy Jesus stayed behind in Jerusalem. His parents did not know it, 44  but supposing him to be in the group they went a day's journey, but then they began to search for him among their relatives and acquaintances, 45  and when they did not find him, they returned to Jerusalem, searching for him."},
    {"time":1383, "text": "<br><strong>Take risks</strong><br><br>Luke 2:43-45 (ESV) Luke 5:11 (ESV) And when they had brought their boats to land, they left everything and followed him."},
    {"time":1632, "text": "<br><strong>Take risks</strong><br><br>John 11:16 (ESV) So Thomas, called the Twin, said to his fellow disciples, 'Let us also go, that we may die with him.'"},
    {"time":1713, "text": "<br><strong>Take risks</strong><br><br>Acts 14:5-7 (ESV) When an attempt was made by both Gentiles and Jews, with their rulers, to mistreat them and to stone them, 6  they learned of it and fled to Lystra and Derbe, cities of Lycaonia, and to the surrounding country, 7  and there they continued to preach the gospel."},
    {"time":1813, "text": "<br><strong>Take notice of the wisdom of others</strong>"},
    {"time":2402, "text": "<br><strong>Get involved in church</strong>"},
    {"time":2840, "text": "<br><strong>Become a servant</strong>"}
  );
/*
 Preparing For Ministry

Develop good habits
Luke 2:39-40
Luke 2:41-42
Luke 6:12
Ps 37:3-5
	
Take risks
Luke 2:43-45
Luke 5:11
John 11:16
Acts 14:5-7

Take notice of the wisdom of others
Luke 2:46-48
Luke 3:16
Acts 6:10
Acts 11:22-24

Get involved in church
Luke 2:49
Heb 10:23-25
Acts 20:28

Become a servant
Luke 2:50-52
1 Tim 4:6
Gal 5:13
Phil 1:1 


  */
  $(document).ready(function() {
    $(".dnloader").removeClass("hidden").hide();
    $(".hidden").removeClass("hidden").hide();
    $("#t"+activePane).addClass("current");

$.log("wcc js ready");

    $('.aud').click(function(){
      playBack(this ,false);
      return false;
    });
  
    $('.vid').click(function(){
      playBack(this, true);
      return false;
    });

/**
 * play audio or video
 * @param obj {element}
 * @param vid {Boolean}
 */
    function playBack(obj,vid){
      var par=$(obj).parents('div').eq(0);
      var typ=(vid)?"Video":"Audio"; 
      jpFile=par.siblings(".title")
        .children(".r5s"+typ).html();
        
      var titles=par.siblings(".title")
        .children("[class^='title']");
        
      vp=par.siblings(".vplayer_wrap");
      
      if (jvOpen) {
        if (vp!=vpPrior) {
          vpPrior.hide();
          vp.show();
        }
      } else {
        vp.show();
      }
      jvOpen=true;
      vpPrior=vp;
      jpPriorFile=jpFile;
      
   $.log ("jpFile:"+jpFile+" *jpPrior: "+jpPriorFile+" jvOpen="+jvOpen);
   
      targ=$("[id^='vplayer']",vp);
   //console.log("targ=>");
   //console.log(targ);
      width=targ.attr("width");
      height=targ.attr("height");
//   $.log ("x:"+x+" y:"+y+" play file:"+jpFile);

      $(targ).append($('#jwp_wrap'));
      if (!height || height<50) {
        height=210;
      }
      if (!width || width<50) {
        width=320;
      }
      
      if (width==320) {
        $("#jw_info_wrap").show();
      } else {
        $("#jw_info_wrap").hide();
      }

      var info="<br><br><br>";
      info+="<strong>"+$(titles[1]).html()+"</strong><br><br>";
      info+=$(titles[2]).html()+"<br><br>";
      info+=$(titles[0]).html()+"<br><br>"+typ;
      
      /*
        init SPRUCE settings
        $("jwp").tjSpruce(div, opt);
      */
      fnInitSpruce({
        div: "jwp",
        file: "media/Videos/"+jpFile,
        msg: "#jw_info",
        msgReady: info,
        play: true
      });
      return false;
    }
    
/*
     $('#jplayer_wrap')
       .insertAfter(dn)           
       .slideDown();
          $('#jplayer_wrap a').attr("href",jpPath+jpFile);

//      $("#jquery_jplayer").jPlayer("setFile", jpPath+jpFile).jPlayer("pause"); // this.element

*/
$('#flowtabs a').click(function(){
      id=this.id[1];
			$.bbq.pushState({ tab: id }); // put state into history
//      doTab(id);     
/*  var hgt=parseInt($('#flowpanes').css("height"));
    hgt=hgt-10;    
    $('#flowpanes').css("height",hgt+"px");
*/
      return false;
    });

		// Bind a callback that executes when document.location.hash changes.
		$(window).bind( "hashchange", function(e) {
			var id = e.getState( "tab" );
			doTab(id);	//was this.id
			return (false);
		});
    
    function doTab(id) {
      if (id==undefined) {id=1};
      $("#t"+activePane).removeClass("current");
      $("#d"+activePane).hide();

      $("#t"+id).addClass("current");
      $("#d"+id).show();
      activePane=id;

//			var href = $(this).attr( "id" );
      
    }
    
    // select #flowplanes and make it scrollable. use circular and navigator plugins
    $("#xxflowpanes").navigator({
      navi: "#flowtabs"
    /*
    ({

      // select #flowtabs to be used as navigator
      navi: "#flowtabs",
   
      // select A tags inside the navigator to work as items (not direct children)
      naviItem: 'a',
   
      // assign "current" class name for the active A tag inside navigator
      activeClass: 'current',
   
      // make browser's back button work
      history: true
   
    });
    */
    });
      

    $("#xxflowpanes").scrollable({ circular: true, speed:600, mousewheel: true }).navigator({
   
      // select #flowtabs to be used as navigator
      navi: "#flowtabs",
   
      // select A tags inside the navigator to work as items (not direct children)
      naviItem: 'a',
      idPrefix: 'pant',
    
      // assign "current" class name for the active A tag inside navigator
      activeClass: 'current',
   
      // make browser's back button work
      history: true
   
    });

    
    $('#topHome').click(function() {
      window.location="#home";
      return false;
    });
    
    $(window).trigger( "hashchange" );
  });
 
  function log (msg,type) {
alert("old log");
   return;
  };
