/***********************************************************************************************************************
DOCUMENT: /core/templates/toyotagofl/includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 8/28/2009
DESCRIPTION: This document contains general javascript functionality used within the site.  Requires jQuery library
************************************************************************************************************************/

//***********************************************************************************************************************
//GENERAL JAVASCRIPT
//***********************************************************************************************************************

var playedyet=0;
$(function() {
	
	$('#email_form').focus(function() {
		var text = $('#email_form').val();
		if(text == "Email Address") {
			$('#email_form').val("");
		}
	}).blur(function() {
		var text = $('#email_form').val();
		if(text == "") {
			$('#email_form').val("Email Address");
		}	
	});
	
});

/**********************************************************************************************************************
/**
* DOCUMENT: /core/plugins/events/front/projects.back.js
* CODE BELOW THESE NOTES DEVELOPED BY: John Amoratis
* COMPANY: Diocese of Juneau Alaska
* DATE: 3/6/2011
* DESCRIPTION: It was requested by the bishop and coworkers that our slideshow have
* forward and backward buttons as well as a pause feature. The jquery plugin being
* used for the original slide show was the lite version of 
* jQuery Cycle Plugin as annotated above. The only pause function
* in that lite version was the mouse hovering above the slideshow itself.
* But in order to have the slideshow remain paused even as the
* mouse hovered above the forward and backward buttons, I had to switch out the code to the full version
* of the jQuery Cycle Plugin in order to have the ability to pause slideshow from the
* rollover buttons themselves. The following javascript is used to
* show and hide the buttons via animation of divs and control rollovers, etc.
* 
*/
			function show_or_exit_controls(whichway)
			{
				
				whichdirection = whichway;
				doTimer();
			}
			
			function lightuparrows(whicharrow)
			{
				if(whicharrow=='left')
				{
				$('#slideshow').cycle('pause');
				document.getElementById('left_arrow_image').src = "core/plugins/presentation/images/left_front_page_slideshow_arrow_semi_illuminated.png";
				}else if(whicharrow=='leftoff')
				{
				$('#slideshow').cycle('resume');
				document.getElementById('left_arrow_image').src = "core/plugins/presentation/images/left_front_page_slideshow_arrow.png";
				}
				else if(whicharrow=='right')
				{
				$('#slideshow').cycle('pause');
				document.getElementById('right_arrow_image').src = "core/plugins/presentation/images/right_front_page_slideshow_arrow_semi_illuminated.png";		
				}else if(whicharrow=='rightoff')
				{
				$('#slideshow').cycle('resume');
				document.getElementById('right_arrow_image').src = "core/plugins/presentation/images/right_front_page_slideshow_arrow.png";	
				}else if(whicharrow=='rightclicked')
				{
				document.getElementById('right_arrow_image').src = "core/plugins/presentation/images/right_front_page_slideshow_arrow_illuminated.png";	
				}else if(whicharrow=='leftclicked')
				{
				document.getElementById('left_arrow_image').src = "core/plugins/presentation/images/left_front_page_slideshow_arrow_illuminated.png";	
				}
			}

// THIS COUNTER IS USED FOR THE ANIMATION OF THE NAVIGATION BUTTONS
// AND NEWS DIV ON THE INDEX PAGE SLIDESHOW
var c=0;
var t;
var timer_is_on=0;
var whichdirection = 'up';

function timedCount()
{
	
		
		document.getElementById('feature-news').style.width=260-c*2+"px";
		document.getElementById('jwa-left-arrow').style.width=c+"px";
		document.getElementById('jwa-right-arrow').style.width=c+"px";
		  
			if(c<=19 && c >=-1)
			{
				if(whichdirection == 'up' && c<19)
				{
				c=c+1;
				} else if(whichdirection == 'down')
				{
					
					if(c>0)
					{
					c=c-1;
					}
				}
				t=setTimeout("timedCount()",25);
			}
			
}

function doTimer()
{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount();
  }
}

//FOR THE SEARCH BOX INCLUDED IN THE TOP HEADER NAV

// Google Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

//Enter domain of site to search.

    
 
var domainroot="dioceseofjuneau.org"

function Gsitesearch(){
	if(event.keyCode == 13){
		window.location = "http://www.google.com/search?q=site:"+domainroot+"%20"+document.getElementById('srch_fld').value;
 
	}
}

//WHEN THE PRINT ICON IS CLICKED, THIS SECTION OF CODE PREPARES TWO DIVS,
//A REAR DIV THAT IS MADE TRANSLUCENT TO DARKEN THE WEB PAGE, AND THEN
//A DIV WHICH IS ACTUALLY FILLED WITH THE CONTENT THAT WILL BE PRINTED
//ONCE THESE DIVS ARE PREPARED, A TIMER IS STARTED THAT MANIPULATES THESE
//DIVS SO THAT FIRST, THE REAR ONE IS DARKENED, AND SECOND, THE DIV WITH
//THE CONTENT IS SLOWLY RAISED INTO THE SCREEN.
function makeView(){
x = document.getElementById("printDivBackground");
x.style.position="fixed";
x.style.width="100%";
x.style.height="100%";
x.style.backgroundColor="Black";
x.style.opacity="0";

x = document.getElementById("printDiv");
x.style.position="fixed";
x.style.overflow="scroll";
x.style.top="0";
x.style.top="100%";
x.style.width="60%";
x.style.height="100%";
x.style.backgroundColor="white";
x.style.opacity="1";
x.style.left = "20%";
x.style.visibility = "visible";
y = document.getElementById("content");
x.innerHTML = "&nbsp<br>&nbsp<br><center><input type=\"button\" value=\"Print\" onClick=\"doActualPrint()\">&nbsp&nbsp&nbsp<input type=\"button\" value=\"E-Mail A Link to This Page\" onClick=\"javascript:window.location=\'mailto:place an address here?subject=A Link to a Page On DioceseofJuneau.org&body=Hello! I thought you would like this link from dioceseofjuneau.org: %0A" + location.href + "\'\">&nbsp&nbsp&nbsp<input type=\"button\" value=\"Done\" onClick=\"removePrintView()\"></center>&nbsp<br>&nbsp<br><!--END_PRINT_HEADER-->"+ y.innerHTML;


whichdirectionForPrint = 'in';
doTimerForPrintView();
}

//FOLLOWING ON THE LAST TWO LINES OF THE ABOVE CODE,
//THIS SECTION OF CODE HANDLES THE ACTUAL ANIMATION OF
//THE PRINT PREVIEW DISPLAY TO DARKEN THE REAR DIV AND
//RAISE THE DIV WITH THE PRINT CONTENT
var cForPrint=0;
var tForPrint;
var timer_is_on_for_print=0;
var whichdirectionForPrint = 'in';

function timedCountForPrint()
{
	
		if (cForPrint > 0 && cForPrint < 8)
		{
			document.getElementById('printDivBackground').style.display="inline";
			document.getElementById('printDivBackground').style.opacity=cForPrint*.1+"";
			document.getElementById('printDivBackground').style.filter="alpha(opacity="+(cForPrint*10)+")";
		}
		
		if (cForPrint < 1)
		{
			document.getElementById('printDivBackground').style.display="none";
		}
		document.getElementById('printDiv').style.top=1000-(cForPrint*20)+"px";
		  
			if(cForPrint<=50 && cForPrint >=-1)
			{
				if(whichdirectionForPrint == 'in' && cForPrint<50)
				{
				 cForPrint=cForPrint+1;
				} else if(whichdirectionForPrint == 'out')
				{
					
					if( cForPrint>0)
					{
					 cForPrint= cForPrint-1;
					}
					
				}
				tForPrint=setTimeout("timedCountForPrint()",20);
			}
			
			
}

function doTimerForPrintView()
{
	
	if (!timer_is_on_for_print)
  		{
  		timer_is_on_for_print=1;
  		timedCountForPrint();
 		}
}

//ONCE THE PRINT VIEW IS DISPLAYED... THE FOLLOWING CODE HANDLES
//THE BUTTON FUNCTIONS

//WHEN THE PRINT BUTTON IS CLICKED
function doActualPrint(){
	var content = document.getElementById("printDiv");
	var pri = document.getElementById("ifmcontentstoprint").contentWindow;
	pri.document.open();
	
	cihtml = content.innerHTML;
	cihtml_array = content.innerHTML.split("<!--END_PRINT_HEADER-->");
	pri.document.write(cihtml_array[1]);
	pri.document.close();
	pri.focus();
	pri.print();
}


//WHEN THE DONE BUTTON IS CLICKED
function removePrintView()
{
	whichdirectionForPrint = 'out';
	doTimerForPrintView();
}

//THE PRINT VIEW DISPLAY ALSO CONTAINS AN E-MAIL LINK BUTTON.
//THE JAVASCRIPT CODE ASSOCIATED WITH THAT BUTTON IS NOT HERE.
//IT IS CONTAINED IN THE ACTUAL ONCLICK EVENT WITHIN THE CODE
//FOR THAT BUTTON.

//WHEN THE MOUSE IS MOVED INTO OR OUT OF THE CONTENT DIV IN WEB VIEW
function printViewButtonRollover(whichmode)
{
	if (whichmode == 'show')
		{
		document.getElementById('printIconGraphic').src="http://www.dioceseofjuneau.org/core/templates/dioceseofjuneau/web/images/printer.png";
		}else if (whichmode =='showWithNoBorder')
		{
		document.getElementById('printIconGraphic').src="http://www.dioceseofjuneau.org/core/templates/dioceseofjuneau/web/images/printerNoBorder.png";
		}else if (whichmode =='hide')
		{
		document.getElementById('printIconGraphic').src="http://www.dioceseofjuneau.org/core/templates/dioceseofjuneau/web/images/printerBlank.png";
		}
}
	
	
//JAVASCRIPT FOR WYD BANNER AD
//JUNE 2011
//JOHN A

function show_banner_media(){
	
	document.getElementById('wyd_banner_table').style.visibility = 'visible';
	
	 
     
	//var movieb = window.document.player1;//document.getElementById('player1');
     // window.document[player1].play();
      //document.getElementById('player1').play();
	$('#wyd_banner_table').fadeTo('slow', 1, function() {
      // Animation complete.
      var movieb = window.document.player1;//document.getElementById('player1');
      
      if (playedyet!=1)
      {
      PlayFlashMovie();
      playedyet=1;
      }
    });
	
	
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject("player1");
	flashMovie.Play();
	//embed.nativeProperty.anotherNativeMethod();
}

