$(document).ready(function(){
	
	/* PNGFIX start *******************************************************************/
		$(document).pngFix();
	/* PNGFIX end *********************************************************************/
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[@rel$="external"]').click(function(){
		this.target = "_blank";
	});	
	/* EXTERNAL LINKS end *************************************************************/

	/*SEARCH*/
	$('#search input.text').focus(function(){	if(this.value=='Search') {	$(this).val('');} });
	$('#search input.text').blur(function(){ if(this.value =='') {	$(this).val('Search');}	});
	/*SEARCH*/
	
	/* NAVIGATION start ***************************************************************/
	//$('#nav ul ul').prepend('<li class="top"></li>');
	//$('#nav ul ul').append('<li class="bottom"></li>');
	//$('#nav ul ul').hide();
	//hover show next level
	$('#nav ul > li').hover(function() { $('ul:first', this).show(); },function() {$('ul:first', this).hide();});
	//add class for flyouts
	//if ($('#nav ul ul ul').length > 0) { $('#nav ul ul ul ').parent().addClass('flyout'); }
	
	
	/* SLIDESHOW start **************************************************************/
	setInterval( "slideSwitch()", 5000 );
	setInterval( "slideSwitch2()", 3000 );
	/* SLIDESHOW end ****************************************************************/	
	
	
	$('#nav li.menu-cat:first').addClass('first');
	$('#nav li.menu-cat:last').addClass('last');
	/* NAVIGATION end ****************************************************************/
	
	/*DISCLAIMER*/
	$('#links-account a,a.disclaimer').click(function(){ alert('You are leaving the Evans Bank web site. The hyperlink is provided for your convenience only. Evans Bank is not responsible for, nor guarantees the accuracy of the information contained in this site.'); });
	/*DISCLAIMER*/
	
	/*CLEAN UP FORMS*/
	$('.cTimeValue input[type="text"],.cTimeValue select').addClass('text');
	$('.cTimeValue input[type="submit"]').addClass('button');
	/*CLEAN UP FORMS*/
	
	/* SIFR***************************************************************************/
	sifr('.font-01','font-archer-bold',2.4);
	/* SIFR**************************************************************************/
		
}); //close document.ready


/* SLIDESHOW function start *********************************************************/
function slideSwitch() {
	var $active = $('#slideshow img.active');

	if ( $active.length == 0 ) $active = $('#slideshow img:last');

	var $next =  $active.next('img').length ? $active.next()
			: $('#slideshow img:first');

	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 500, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/

/* SLIDESHOW function start *********************************************************/
function slideSwitch2() {
	var $active = $('#slideshow2 span.active');

	if ( $active.length == 0 ) $active = $('#slideshow2 span:last');

	var $next =  $active.next('span').length ? $active.next()
			: $('#slideshow2 span:first');

	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 500, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/

/* SIFR function start **************************************************************/
function sifr(x,font,adj){
$(x).flash(
	{ src: '/includes/media/'+font+'.swf' },
	 { version: 8 },
		function(htmlOptions) {
			var charlength = (this.innerHTML.length) * $(this).height()/adj;
			htmlOptions.flashvars.css = '*%20%7B%20color%3A%23'+RGBstring($(this).css('color'))+'%7D';
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<span>'+this.innerHTML+'</span>';
			var $alt = $(this.firstChild);
			htmlOptions.width = charlength; //$alt.width()
			htmlOptions.height = $(this).height(); //$alt.height()
			$alt.addClass('sifr-alt');
			$(this).addClass('sifr-text-alt').prepend($.fn.flash.transform(htmlOptions));						
		}
	).css({visibility:'visible'});
}
/* SIFR function end ****************************************************************/

/* sIFR RGB conversion function start **********************************************/
function RGBstring(str) {
	str1 = str.replace("#","");
	str2 = str1.replace("rgb(","");
	str2 = str2.replace(")","");
	str2 = str2.split(",");
	if(navigator.appName == "Microsoft Internet Explorer"){ return str1; }
	else { return toHex(str2[0])+toHex(str2[1])+toHex(str2[2]); }
}
function toHex(N) {
 if (N==null) return "01";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}
/* sIFR RGB conversion function end *************************************************/