$(document).ready(function() {
	
    // locations animation
    $("#locations").cycle({fx:'fade', delay: -200, speed: 600 });
    
    // home page grid animation
	$(".grid_animation").cycle({fx:'fade', delay: -200, speed: 600 });
	
	function getPic(num) {
		var bodyId = $("body").attr("id");
        // get the right file type
        if(bodyId == "location"){
          var fileType = "png";
        }
        else {
          var fileType = "jpg";
        }
		var filename = bodyId+"_"+num+"."+fileType;
		return filename;
	}
	
	$("#right_col h3").click(function() {
	      if ($(this).parent().height() == 20){
	    	  $(".collapse-x").addClass("collapse");
	    	  $(".collapse-x").removeClass("collapse-x");
	    	  $(this).parent().addClass("collapse-x");
	    	  $(this).parent().removeClass("collapse");
	    	  if ($("body").attr("id")) {
	    	    var picnum = $("#right_col h3").index(this)+1;
	    	    var picname = getPic(picnum);
	    	    $("#left_col img").attr({src: "images/"+picname});
	    	  }
	    		  
	      }
	      else {
	    	  $(this).parent().addClass("collapse");
		      $(this).parent().removeClass("collapse-x");
	      }
	    });
	
	
});