var news_item = 1;

news_timer = function () {
/*	$('#news-block').stopTime("change-news", ""); */
	$('#news-block').oneTime(8000, "change-news", function() {news_change();} );
}

news_change = function () {
	if (news_item == 1) {
		$('#news-block').fadeTo(1500,0.2,function () {
			$('#news-block').html('<p align="center"><a href="http://theoracleinstitute.org/deas">Deas</a></p><p align="center"><a href="http://theoracleinstitute.org/deas">and other imagings</a></p><p style="margin-top: 6px"><a href="http://theoracleinstitute.org/deas"><img alt="" src="http://theoracleinstitute.org/images/Books/deas-thumb.jpg" style="margin: 0px auto; width: 120px; display: block; height: 180px" /></a></p>');
			news_item = 2;
		}),
		$('#news-block').fadeTo(3000,1);
	} else {
		$('#news-block').fadeTo(1500,0.2,function () {
			$('#news-block').html('<p align="center"><a href="http://theoracleinstitute.org/trustingdoubt">Trusting Doubt:</a></p><p align="center"><a href="http://theoracleinstitute.org/trustingdoubt">A Former Evangelical Looks at Old Beliefs in a New Light</a></p><p style="margin-top: 6px"><a href="http://theoracleinstitute.org/trustingdoubt"><img alt="" src="http://theoracleinstitute.org/images/Books/trusting_doubt_thumb.jpg" style="margin: 0px auto; width: 120px; display: block; height: 179px" /></a></p>');
		news_item = 1;
		}),
		$('#news-block').fadeTo(3000,1);
	}
	news_timer();
}

/************  These are for the rolling authors list - on the Love page and maybe elsewhere *********/
authors_clear  = function () {
	$('#authors-list').css({'background-image':''});
	$('#authors-list').html('<IMG alt="" src="http://theoracleinstitute.org/images/091409_0640_books5.png" width=200 height=297>');
}
authors_start = function (list) {
	$('#authors-list').stopTime("clear", "");
	$('#authors-list').css({'background-image':'url("../images/authorslist.png")'});
	getAuthors(list);
}
authors_timer = function () {
	$('#authors-list').oneTime(1000, "clear", function() {authors_clear();} );
}

getAuthors = function(chap){
   $.get("http://theoracleinstitute.org/cms/authors.php",{ chapter: chap },
            function(data){
                $('#authors-list').html('<h4>Contributing Authors:</h4>' + data.returnValue);
            }, "json");
}

getCritics = function(){
   var shtml
   $('.critical-acclaim').html(""); 
   $.get("http://theoracleinstitute.org/cms/critics.html", 
     function(data){
   	   $('.critical-acclaim').html( "<div>" + data + "</div>");
     }
   );
   $.get("http://theoracleinstitute.org/cms/buynow.html", 
	 function(data){
	   $('.buynow').html(data);
      }
   );
/*   	   alert($('.critical-acclaim').html()); */
}

/**********   The pop-up descriptions of the front page 5 areas *******/
description_clear = function () { 
	$('#fp-description').fadeTo("fast",0);
	$('#fp-image').fadeTo("fast",1.0);
}
description_timer = function () {
	$('#fp-description').oneTime(1000, "clear-description", function() {description_clear();} );
}
description_start = function (theHtml) {
	$('#fp-description').stopTime("clear-description", "");
	$('#fp-description').html(theHtml);
	$('#fp-description').fadeTo("fast",1);
	$('#fp-image').fadeTo("fast",0.90)
}

/**********  A test Logging Function ********/
jQuery.fn.log = function (msg) {
  console.log("%s: %o", msg, this);
  return this;
};
            
$(function() {

	$('#fp-description').fadeTo("fast",0);

	news_timer();
/*	
	$('#news-block').hover (
		function() {$(this).stopTime("change-news", "");},
		function() {news_timer();}
	);
*/
	$('#authors-list').hover (
		function() {$(this).stopTime("clear", "");},	        	
		function() {authors_timer();}
	);
	
	$('.authors-chap1').hover (
		function() {authors_start('1');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap2').hover (
		function() {authors_start('2');},	        
		function() {authors_timer();}
	);
	
	$('.authors-chap3').hover (
		function() {authors_start('3');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap4').hover (
		function() {authors_start('4');},	        	
		function() {authors_timer();}
	);
	$('.authors-chap5').hover (
		function() {authors_start('5');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap6').hover (
		function() {authors_start('6');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap7').hover (
		function() {authors_start('7');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap8').hover (
		function() {authors_start('8');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap9').hover (
		function() {authors_start('9');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap10').hover (
		function() {authors_start('10');},	        	
		function() {authors_timer();}
	);

	$('.authors-chap11').hover (
		function() {authors_start('11');},	        	
		function() {authors_timer();}
	);
	
	$('#fp-trigger2').click(
		function() {
			$('#fp-image2').fadeTo("fast",0);
			$("#fp-movie2").html( "<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' 	                	codebase='http://www.apple.com/qtactivex/qtplugin.cab' height='510' width='680' id='qtmovie'><param name='src' value='http://www.theoracleinstitute.org/movies/pentacle.mov' /><param name='autoplay' value='true'/><param name='postdomevents' value='true' /><param name='scale' value='tofit'/><param name='type' value='video/quicktime' width='680' height='510'/><embed src='http://www.theoracleinstitute.org/movies/pentacle.mov' height='510' width='680' NAME='qtmovie' id='qtmovieid'  autoplay='true' scale='tofit' postdomevents='true' />type='video/quicktime' pluginspage='http://www.apple.com/quicktime/download/' /></object>");
		}
	);
	
	$('#fp-trigger2').hover(
		function() {
			$(this).css({cursor:'pointer'});
		},
		function() {
			$(this).css({cursor:'auto'});
		}
	);
	
	$('#fp-trigger').hover(
		function() {
			$(this).css({cursor:'pointer'});
		},
		function() {
			$(this).css({cursor:'auto'});
		}
	);

	$('#fp-trigger').click(
		function() {

			$('#fp-image').fadeTo("fast",0);
			$('#fp-image').css({visible:'false'});
			$('#fp-institute').css({visible:'false'});
			$('#fp-press').css({visible:'false'});
			$('#fp-school').css({visible:'false'});
			$('#fp-independence').css({visible:'false'});
			$('#fp-integral').css({visible:'false'});
			$('#fp-body').css({'width':'684'});
			$('#fp-movie').media({
				src:"http://www.theoracleinstitute.org/movies/pentacle.mov",
				width:680,
				height:510,
				attrs :{scale:'tofit', autoplay:'true', controller:'false' },
				autoplay:true
			});
		}
	);

	$('#fp-description').hover (
		function() {$(this).stopTime("clear-description", "");},	        	
		function() {description_timer();}
	);

	$('#fp-institute').hover (
		function() {description_start('<h3>Our Three Basic Principles:</h3><p><a href="/truth">The Truth</a>, which sets us free;<br /><a href="/love">The Love</a>, which makes us whole; and<br /><a href="/books">The Light</a>, which guides us toward one shared destiny.');},	        	
		function() {description_timer();}
	);

    $('#fp-press').hover (
		function() {description_start('<h3>Our Commitment:</h3><p>To publish books that assist humanity through the current spiritual chaos and into the <a href="/millennium">New Millennium</a></p>');	},
		function() {description_timer();}
    );

	$('#fp-school').hover (
		function() {description_start('<h3>Our Theosophy:</h3><p>The <a href="/saddha">Saddha</a> process of soul growth, which transforms faith into positive action.</p>');},
		function() {description_timer();}
	);

	$('#fp-independence').hover (
		function() {description_start('<h3>Our Vision:</h3><p >To build a sustainable spiritual community in <a href=/independence">Independence, Virginia.</a></p>');},
		function() {description_timer();} 
	);

	$('#fp-integral').hover (
		function() {description_start('<h3>Our Goal:</h3><p>To help humanity adopt a new <a href="/paradigms">Spiritual Paradigm</a> that transcends the man-made religions.</p>');},
		function() {description_timer();}
	);
});


