var BLUE = function() {
      
   function skinSite() {
      //$("#head").append('<div class="beige-shadow-left-circle"></div><div class="beige-shadow-right-circle"></div>');
      
      $("#container").append('<div id="container-shadow-left-circle"></div><div id="container-shadow-right-circle"></div>');
      $("#container").wrap('<div id="wrap2"></div>');
      
      $("div.wrap").wrap('<div class="outer2"></div>').wrap('<div class="beige-shadow-right-circle"></div>');
      $("div.wrap").wrap('<div class="outer1"></div>').wrap('<div class="beige-shadow-left-circle"></div>');
		/*
		//add footer to each page
		$.get("/assets/php/includes/footer.inc.php", function(data){
			$("#wrap").after(data);
		}); */
   }
   
   function setSubContentSidebar() {
      var cSidebarHeight = $("div#content-sidebar ul:first").height();
      var cContentHeight = $("div#content div#content-main").height();

      //if the subpage content sidebar is shorter than the main content section redraw it's height
      if(cContentHeight > cSidebarHeight)
      {
         var emHeight = (cContentHeight -  cSidebarHeight) / 10;
         $("div#content-sidebar ul:first").css("padding-bottom", emHeight + "em");
      }
   }
   
   function ie6() {
      return (window.external && (typeof window.XMLHttpRequest == "undefined"));
   }
   
   function ie7() {
      return (window.external && (typeof window.XMLHttpRequest == "object"));
   }
   
   return {
      init : function() 
      {
         //BLUE.searchSetup('#query', '.search', 'Enter Your Search Term');
         //BLUE.searchSetup('#query2', '#search2', 'Enter Your Search Term');
         //BLUE.searchSetup('#q', '#search', 'Enter Your Search Term');
         BLUE.searchSetup('#zip', '#find-by-zip', 'Enter city, county or zip code');
         skinSite();
         setSubContentSidebar();

			//site dropdown menu
         $('#head-nav ul>li').hover(
            function () {
               $(this).addClass("sfHover");
            }, 
            function () {
               $(this).removeClass("sfHover");
            }         
         );
			
			//alternate table row colors
			$("#content table tbody tr:odd").addClass("highlight");
			
			//add styles for table rows when hovered
			$("#content table tbody tr").hover(
				function () {
					$(this).addClass("tr-hover");
				},
				function () {
					$(this).removeClass("tr-hover");
				}
			);
			
			//make a table row clickable, and highlight the row
			$("#content table tbody tr").click(function () { 
				$(this).toggleClass("tr-click"); 
			});
			
			//Add support text for parish search
			$('#find-parish').prepend('<p class="help-text">Search for a parish by entering zip code OR city, state OR county, state OR select a parish from our list.</p>');

		},
		
		searchSetup : function (input, form, initialValue) {
			var initializedSearch = initialValue;
			
			$(input).addClass('lightText');
			$(input).val(initializedSearch);
			
			$(input).focus(function(){
												
				$(input).addClass('darkText');
				$(input).removeClass('lightText');
					
				var $query = $.trim($(input).val()).toLowerCase();
				
				if($query == initializedSearch.toLowerCase())
				{
					$(input).val('');
				}
			});
			
			$(input).blur(function(){
												
				$(input).addClass('darkText');
				
				var $query = $.trim($(input).val()).toLowerCase();
				
				if($query == '')
				{
					$(input).addClass('lightText');
					$(input).removeClass('darkText');
					$(input).val(initializedSearch);
				}
			});
			
			$(form).submit(function() {
				var $query = $.trim($(input).val()).toLowerCase();
				
				if($query != initializedSearch.toLowerCase())
				{
					return true;   
				}
				else
				{
					alert("Please enter a valid search");
					return false;
				}
			});
		},
      
      /***
      Thank you Dustin Diaz for these cookie functions
      ***/
      getCookie : function ( name ) {
         var start = document.cookie.indexOf( name + "=" );
         var len = start + name.length + 1;
         if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
            return null;
         }
         if ( start == -1 ) return null;
         var end = document.cookie.indexOf( ';', len );
         if ( end == -1 ) end = document.cookie.length;
         return unescape( document.cookie.substring( len, end ) );
      },
   
      setCookie : function ( name, value, expires, path, domain, secure ) {
         
         var today = new Date();
         today.setTime( today.getTime() );
         if ( expires ) {
            expires = expires * 1000 * 60 * 60 * 24;
         }
         var expires_date = new Date( today.getTime() + (expires) );
         document.cookie = name+'='+escape( value ) +
            ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
            ( ( path ) ? ';path=' + path : '' ) +
            ( ( domain ) ? ';domain=' + domain : '' ) +
            ( ( secure ) ? ';secure' : '' );
      },
   
      deleteCookie : function ( name, path, domain ) {
         if ( BAI.getCookie( name ) ) document.cookie = name + '=' +
               ( ( path ) ? ';path=' + path : '') +
               ( ( domain ) ? ';domain=' + domain : '' ) +
               ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
      }
            
   };
   
}();

$(document).ready(function() {
   BLUE.init();
});