// JavaScript Document

$(document).ready(function() {
	setOpacity('slideshowtext_background');
	$("#slideshow").css("visibility","visible");
	var cNumber = 0;
    $('#slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout:6000,
		speed:600,
		autostop: true,     // true to end slideshow after X transitions (where X == slide count) 
	    autostopCount: 7, 
		before: onBefore
		
	});
	
$(".read_more_link").click(function(event){
     $(".read_more").slideToggle('slow');
     if ($(".read_more_link").html() == "Hide"){
     	$(".read_more_link").html('Read more...');
     }
     else {
     	 $(".read_more_link").html('Hide');
     }
   });
	
$("#moreSigs").click(function(event){
	event.preventDefault()
     $("#plea_sigs").slideDown('slow');

   });	
	
//$('a.media').media( { width: 300, height: 20 } );
$("a.noclick").click(function(event){
	event.preventDefault();
   });	   

$("#thesearch").focus(function() {
      $(this).val('');
	});  

$.jatt({
	  // options that can be modified by metadata
	  direction   : 'n',     // direction of tooltip
	  followMouse : false,    // tooltip follows mouse movement
	  content     : 'title', // attribute containing tooltip text
	  speed       : 300,     // tooltip fadein speed
	  local       : false,   // if true, the script attachs the tooltip locally; if false, the tooltip is added to the body
	  xOffset     : 10,      // x distance from mouse (no negative values)
	  yOffset     : 10,      // y distance from mouse (no negative values)
	  zIndex      : 1000,    // z-index of tooltip

	  // options not supported by metadata
	  live        : false,                 // use live event support?
	  metadata    : 'class',               // attribute that contains the metadata, use "false" (no quotes) to disable the metadata.
	  activate    : 'mouseenter focusin',  // how tooltip is activated
	  deactivate  : 'mouseleave focusout', // how tooltip is deactivated

	  // change tooltip, screenshot and preview class
	  tooltip     : '.tooltip',            // tooltip class 
	  screenshot  : 'a.screenshot',        // screenshot class
	  preview     : 'a.preview',           // preview class
	  
	  // tooltip & preview ID (div that contains the tooltip)
	  tooltipId   : 'tooltip',             // ID of actual tooltip
	  previewId   : 'preview'              // ID of screenshot/preview tooltip 
	 });   

});//End Document Ready


function onBefore() { 
var thetext = $(this).children("div").html();

    var textArray = thetext.split(" ");
	//alert (textArray[0]);
	if (textArray[0] == "<span" || textArray[0] == "<SPAN"){theEnd(thetext)}else {
	$('#slideshowtext').fadeOut(0, function() {
		$('#slideshowtext').html(thetext); 
		$('#slideshowtext').delay(600).fadeIn(500);//.delay(4300);//.fadeOut(600); 
  	});
	}
};


function theEnd(thetext) { 
	var textArray = thetext.split("<br><br>");
	var thecount = textArray.length;
	if (thecount == 1){textArray = thetext.split("<BR><BR>");}
    //alert (textArray[0]);
	$('#slideshowtext').fadeOut(0, function() {
		$('#slideshowtext').html(textArray[0]); 
		$('#slideshowtext').delay(700).fadeIn(500);//.delay(4300);//.fadeOut(600); 
		$('#slideshowtext1').html(textArray[1]); 
		$('#slideshowtext1').delay(3000).fadeIn(500);
		$('#slideshowtext2').html(textArray[2]); 
		$('#slideshowtext2').delay(5300).fadeIn(500);
  	});
};



function setOpacity(div) {
	document.getElementById(div).style.opacity = .4;
	document.getElementById(div).style.filter = 'alpha(opacity=' + 40 + ')';
}



