
$(document).ready(function() {  
  
  function imageresize() {  
    var content_width = screen.width;
	  var image_count = $('.fluidimage').size();
	  for(i=0; i<image_count; i++) {
	    var image_path = $('.fluidimage')[i].src;
	    var image = image_path.substring(image_path.lastIndexOf('/') + 1);
      if(content_width < 481) {  
        $('.fluidimage')[i].src = '/images/mobile/' + image;  
      } else {  
        $('.fluidimage')[i].src = '/images/' + image; 
      }  
	    // Removes attrs of all items in the array
	    $('.fluidimage').removeAttr('width');
	    $('.fluidimage').removeAttr('height');	  
    }  
  }
  
  imageresize();//Triggers when document first loads   
  
	
	function show_mobile_items_only() {
		var content_width = screen.width;
	  if(content_width < 481) {
			$('#header').html('');
			$('#always_changing').html('<h1 class="h1_content_title">Always Changing:</h1><br />');
			//$('#twitter_status').remove();
			$('#weekly_video_area').remove();
			$('#whats_happening').html('<h1 class="h1_content_title">What\'s Happening:</h1><br />');
			$('#slides_area').remove();
			
			// Videos
			$('#small_group_video object').attr('width', 310);
			$('#small_group_video object').attr('height', 207);
			$('#small_group_video object embed').attr('width', 310);
			$('#small_group_video object embed').attr('height', 207);
		}
	}
	
	show_mobile_items_only();
	
	
  $(window).bind("resize", function() { //Adjusts image when browser resized  
    imageresize();  
  });  
  
	
  
  // Used on the giving page
  $('img#give_online').hover(
    function() { $(this).attr("src","/images/GIVEONLINE-ON.jpg"); }, 
	  function() { $(this).attr("src","/images/GIVEONLINE.jpg"); }
  );

  
});  


function alternate_chipin_rows() {
	var chipin_areas = $('.chipin_area');
	var num_areas = chipin_areas.size();
	var row_classes = ['chipin_odd_row', 'chipin_even_row'];
	for(i=0; i<num_areas; i++) {
		chipin_areas[i].className += ' ' + row_classes[i%2];
	}
}
