$(document).ready(function(){
	var currentPosition = 0;
  var slideWidth = 176;
  var slides = $('.slide');
  var numberOfSlides = slides.length;
  var sam;
  var doslides ="yes";		
  //alert ("the number of slides is" +numberOfSlides);
		//alert("test docready " + this.title);
		slide("#navlinks", 0, 0, 100, 1.1);

$(".answer").slideUp(500);
$(".question").click(function(){
	//alert ("found a question " + this.name + " title:"  + this.title);
	//$(".answer").slideUp(500);
	$("#answer"+this.title).slideDown(500);
	$("#question"+this.title).slideUp(500);
		//id="answer1" class="question"
});
$(".less").click(function(){
	//global titlet;
	//titlet=this.title;
	//alert ("found a less " + this.name + " title:"  +  titlet);
		$("#answer"+this.title).slideUp(500);
		$("#question"+this.title).slideDown(500);
		//id="answer1" class="question"
});

	  $('#slidesContainer').css('overflow', 'hidden');
  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });


  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  /*$('#slideshow')
    .prepend('<span class="control" id="leftControl">Move left</span>')
    .append('<span class="control" id="rightControl">Move right</span>');
  */
  manageControls(currentPosition);
  if(numberOfSlides>1 && doslides =="yes"){
	  
	$sam=$.timer(2000, function (timer) {
	//alert ("started timer");
	gallery();
  });
	
  }
function gallery(){
	if(doslides =="yes"){//alert("attempting to run gallery");
	currentPosition = (currentPosition==(numberOfSlides-1)) ? 0 : currentPosition+1;

    //alert("hello! " + numberOfSlides + " " + currentPosition);
	
	$('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
    });
	}
}
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
    }


	});//end document ready function





$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 150;
  var slides = $('.slide');
  var numberOfSlides = slides.length;
  var sam;
  var doslides ="yes";
  
    $('#slidesContainer').css('overflow', 'hidden');



 
  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });


  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  $('#slideshow')
    //.prepend('<span class="control" id="leftControl">Move left</span>')
    //.append('<span class="control" id="rightControl">Move right</span>');
  manageControls(currentPosition);
  //$('#content').append(links);
  //$('.content').append(links);
  //alert("hmm");
  
//  	$("li.picturejump").css('text-decoration', 'none');

  //alert("hello! " + numberOfSlides + " " + currentPosition + " " +  doslides);
  //$sam=setInterval('gallery()',6000);
  // Hide left arrow control on first load
  //var $sams=window.setInterval('gallery()',6000);
  if(numberOfSlides>1 && doslides =="yes"){
	  
	$sam=$.timer(6000, function (timer) {
	//alert ("started timer");
	gallery();
/*	$("li.picturejump")
    .bind('click', function(){
    // Determine new position
	var jump;
	jump =$(this).attr("title");
	//alert("we want to jump to " +jump);
//      currentPosition = ($(this).attr('id')=='rightControl')
 //   ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(jump);
	  slideshowjump(jump);
	  timer.stop();
      // Move slideInner using margin-left
//      $('#slideInner').animate({
 //       'marginLeft' : slideWidth*(-currentPosition)
  //    });
   });*/
	//timer.stop();
  /* end timer  function*/
  });
	
  }
/*							


  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='rightControl')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      });
   });
*/ 
function gallery(){
	if(doslides =="yes"){//alert("attempting to run gallery");
	currentPosition = (currentPosition==(numberOfSlides-1)) ? 0 : currentPosition+1;

    //alert("hello! " + numberOfSlides + " " + currentPosition);
	
	$('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
    });
	}
}
$("li.picturejump").click(function(){
	//alert ("found a sub nav");								   	
	var jump;
	doslides ="no";
	//timer.stop();
	jump =$(this).attr("title");
	//alert ("found a sub nav with title: " + URL);
	//alert ("found a sub nav " + jump);
	//if(jump == currentPosition){
		slideshowjump(jump);
	//}
	
	//$sam=0;
	
/*	//alert ("Clicked on an attorney link test " + URL + " 2");

*/

});

 // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
    }
function slideshowjump(step){
/*	var newstep;
	currentPosition=currentPosition+1;
	if(currentPosition>step){
		newstep=step-currentPosition;
//		newstep=newstep-1;
	}else{
		newstep=step-currentPosition;
//		newstep=newstep+1;
	}
	//alert(newstep + " stp: " +step + " " + currentPosition);
*/	
	var teststep=step-1;
	if(teststep >-1){
		$('#slideInner').animate({
        'marginLeft' : slideWidth*(-teststep)
    	});
	}else{
	}
	currentPosition=teststep;

/*	$('#slideInner').animate({
        'marginLeft' : slideWidth*(-0)
    });
//  :underline;
	//  text-decoration:none;

    
	//alert ("request to go to " + step);

	if(step>1){
		step=step-1;
		$('#slideInner').animate({
        'marginLeft' : slideWidth*(-step)
    	});
	}
	*///$("li.picturejump").css('text-decoration', 'none');
	//$("#"+step).css('text-decoration', 'underline');
	//$('.links'+i).css('text-decoration', 'underline');
	

/*	baseslideshow();
		for (i=1;i<step;i++){
			gallery();
		}
*/	}
  
/* end document ready */
  });  


