// JavaScript Document
// all the jQuery code goes into document.ready()!!!!!!!!!!!!!!!!!!!!!!!! 
$(document).ready(function(){
	//conditional statement to change bgd according to screen width
	var bodyBgd = $('body');
	if(screen.width <= 1280) {
		bodyBgd.addClass('bg1280');
	}
	if(screen.width > 1280 && screen.width <=1360){
		bodyBgd.addClass('bg1360');
	}
	if(screen.width > 1360 && screen.width <=1440){
		bodyBgd.addClass('bg1440');
	}
	if(screen.width > 1440 && screen.width <=1680){
		bodyBgd.addClass('bg1680');
	}
	if(screen.width > 1680) {
		bodyBgd.addClass('bg1920');
	}	
	//
	
	//contact form validation
	$('#contactForm').validate({
		rules:{
			name: 'required',
			email: 
				{
					required: true,
					email: true
					},
			subject: {required: true},
			message: 'required'		
		}, //end of rules
		 messages: {
			  email: {
				 required: "<br/>Please supply an e-mail address",
				 email: "<br/>This is not a valid email address"
			   }
		 }, //end of messages
		errorPlacement: function(error, element) { 
          error.insertAfter(element);
        }
	}); //end of validate
	$('#contactForm input').addClass('required');
	$('#contactForm #email').addClass('email');
	// pullquotes
	$('#biography p span').addClass('pullquote');
	$('#biography.product span').removeClass('pullquote').addClass('productHeader');
	//organizations
	$('#middlePanelContent #organizations #leftColumn h5').addClass('orgText2');
	$('#middlePanelContent #organizations #rightColumn span').addClass('organizationsText');
	//
	$('#middlePanelContent #organizations span a').prepend('<span class="italic">Website >>></span> ');
	// $('#rightColumn .dallasSafariClub').hide();
	 $('#rightColumn .houstonSafariClub').hide();
	 $('#rightColumn .nationalRifleAssoc').hide();
	 $('#rightColumn .northAmericanHunting').hide();
	 $('#rightColumn .texasWildlifeAssoc').hide();
	 //
	var orgHeader = $('#middlePanelContent #organizations #leftColumn h5');
	orgHeader.click(function(evt){														   
		var title = $(this).attr('title');
			$('#rightColumn .houstonSafariClub').hide();
			$('#rightColumn .dallasSafariClub').hide();
			$('#rightColumn .nationalRifleAssoc').hide();
			$('#rightColumn .northAmericanHunting').hide();
			$('#rightColumn .texasWildlifeAssoc').hide();
		 switch (title) {
			case 'Dallas Safari Club' :
			    $('#rightColumn .dallasSafariClub').fadeIn('slow');
				 break;
		  	case 'Houston Safari Club' :
				$('#rightColumn .houstonSafariClub').fadeIn('slow');
				break;
			case 'National Rifle Association' :
				$('#rightColumn .nationalRifleAssoc').fadeIn('slow');
				break;
			case 'North American Hunting Club' :
				 $('#rightColumn .northAmericanHunting').fadeIn('slow');
				break;
			case 'Texas Wildlife Association' :
				 $('#rightColumn .texasWildlifeAssoc').fadeIn('slow');
				break;
		 }
		})
	//
	$('#biography p').hide();
	$('#biography h1').hide();
	$('#biography ul').hide();
	$('#biography #1').show();
	$('#leftColumn img').hide();
	$('#leftColumn img#first').show();
	var bioPage = $('#bottomNav ul li');
	//
	bioPage.click(function(evt){
		var bioPageTitle = $(this).attr('id');
		$('#biography p').hide();
		$('#biography ul').hide();
		$('#biography h1').hide();
		$('#leftColumn img').hide(); 
		$('#leftColumn #flash').hide();
		$(this).addClass('italic');
		//
		 switch (bioPageTitle) {
			 case '1':
			 	$('#biography #1').fadeIn('slow');
				$('#biography ul#1').fadeIn('slow');
				$('#leftColumn img#first').fadeIn('slow');
			 	break;
			 case '2':
			 	$('#biography #2').fadeIn('slow');
				$('#biography ul#2').fadeIn('slow');
				$('#leftColumn img#second').fadeIn('slow');
				break;
			 case '3':
			 	$('#biography #3').fadeIn('slow');
				$('#biography ul#3').fadeIn('slow');
				$('#leftColumn img#third').fadeIn('slow');
			 	break;
			 case '4':
			 	$('#biography #4').fadeIn('slow');
				$('#leftColumn img#fourth').fadeIn('slow');
				break;
			 case '5':
			 	$('#biography #5').fadeIn('slow');
				$('#leftColumn img#fifth').fadeIn('slow');
			 	break;
			 case '6':
			 	$('#biography #6').fadeIn('slow');
				$('#leftColumn img#sixth').fadeIn('slow');
				break;
			 case '7':
			 	$('#biography #7').fadeIn('slow');
				$('#leftColumn img#seventh').fadeIn('slow');
			 	break;
			 case '8':
			 	$('#biography #8').fadeIn('slow');
				$('#biography h1').fadeIn('slow'); //this is LW's signature on about.php - do not remove!!!
				$('#leftColumn img#eigth').fadeIn('slow');
				break;
			 case '9':
			 	$('#biography #9').fadeIn('slow');
				$('#leftColumn img#ninth').fadeIn('slow');
				break;
			case '10':
			 	$('#biography #10').fadeIn('slow');
				$('#leftColumn img#tenth').fadeIn('slow');
				break;
			case '11':
			 	$('#biography #11').fadeIn('slow');
				$('#leftColumn img#eleventh').fadeIn('slow');
				break;
			case '12':
			 	$('#biography #12').fadeIn('slow');
				$('#biography h1').fadeIn('slow');
				$('#leftColumn img#twelvth').fadeIn('slow');
				break;
			case '13':
			 	$('#biography #13').fadeIn('slow');
				$('#leftColumn img#thirteenth').fadeIn('slow');
				break;
			case '14':
			 	$('#biography #14').fadeIn('slow');
				$('#leftColumn img#fourteenth').fadeIn('slow');
				break;
			case '15':
			 	$('#biography #15').fadeIn('slow');
				$('#leftColumn img#fifteenth').fadeIn('slow');
				break;
			case '16':
			 	$('#biography #16').fadeIn('slow');
				$('#leftColumn img#sixteenth').fadeIn('slow');
				break;
		}
	}); 

//
  $(function() {
    $('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
    $('img.image1').data('ad-title', 'Title through $.data');
    $('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
    $('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');
    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
    galleries[0].addAnimation('wild',
      function(img_container, direction, desc) {
        var current_left = parseInt(img_container.css('left'), 10);
        var current_top = parseInt(img_container.css('top'), 10);
        if(direction == 'left') {
          var old_image_left = '-'+ this.image_wrapper_width +'px';
          img_container.css('left',this.image_wrapper_width +'px');
          var old_image_top = '-'+ this.image_wrapper_height +'px';
          img_container.css('top', this.image_wrapper_height +'px');
        } else {
          var old_image_left = this.image_wrapper_width +'px';
          img_container.css('left','-'+ this.image_wrapper_width +'px');
          var old_image_top = this.image_wrapper_height +'px';
          img_container.css('top', '-'+ this.image_wrapper_height +'px');
        };
        if(desc) {
          desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
          desc.animate({bottom: 0}, this.settings.animation_speed * 2);
        };
        img_container.css('opacity', 0);
        return {old_image: {left: old_image_left, top: old_image_top, opacity: 0},
                new_image: {left: current_left, top: current_top, opacity: 1},
                easing: 'easeInBounce',
                speed: 2500};
      }
    );
  });
  function debug(str) {
    if(window.console && window.console.log && jQuery.browser.mozilla) {
      console.log(str);
    } else {
      $('#debug').show().val($('#debug').val() + str +'\n');
    }
  }
//

$('#map2').hide();
//

//
	



}); // end of document.ready - jQuery