/*
 * Initiate Jquery Functions
 *
 */

//Kick-off / Page Load Functions
$(document).ready(function(){
		
	//New tab popup
	$('a[rel="external"]').attr("target", "_blank");
	
	//AutoPopulate by Andy Stratton
	$(".populate").each( function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	$(".populate").focus(function(){
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("");
		}
	});
	$(".populate").blur(function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	//Email Encrypt
	$(".mask").each(function(){
		var ats, dots, address, i;
		ats = [ ' at ', ' (at) ', ' [at] ' ];
		dots = [ ' dot ', ' (dot) ', ' [dot] ' ];
		address = $(this).html();
		for ( i = 0; i < ats.length; i++ ) {
			address = address.replace(ats[i], '@');
		}
		for ( i = 0; i < dots.length; i++ ) {
			address = address.replace(dots[i], '.');
		}
		$(this).html('<a href="mailto:' + address + '">' + address + '</a>');
	});
	
	//Current Nav State
	var path = location.pathname.substring(1);
	if ( path )
		$('ul.navigation li a[href$="' + path + '"]').parent().addClass("current_page_item");
			
	//Home Banner & Slider
	$('#home_banner').bxSlider({
		wrapper_class: 'bxslider_wrap',
		margin: 0,
		auto: true,
		pause: 4600,
		auto_controls: false,
		controls: false,
		pager: false,
		ticker_controls: false,
		ticker_hover: false,
		auto_hover: false
	});
	
	$('a.about_more').click(function () {
      $("#about_more").slideToggle("fast");
	  return false;
    });
	
	//Fancybox Popup
	$("a.screenshot_large").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300,'autoScale' : false, 'overlayColor' : '#042D10', 'titlePosition' : 'inside'  }); 

	
	//Add last class
	//$('#tag:last-child').addClass('last');
	
	//Zebra Stripe
	//$("#tag:odd").addClass("alt");


});
