$(document).ready(function(){
	
	
	var counter = 0
	var newscounter = 0,
    divs = $('#one, #two, #three, #four, #five');
	news = $('#slideone, #slidetwo, #slidethree');
	
	 $('#slideshow')
    .append('<span class="control" id="back">Back</span>')
    .append('<span class="control" id="forward">Forward</span>');

    function showDiv () {
        divs.fadeOut(0) // hide all divs
            .filter(function (index) { return index == counter % 5; }) // figure out correct div to show
			.fadeIn('slow');
		$().css({'behavior' : 'url(/js/iepngfix.htc;'});
													   
			
        counter++;

    }; // function to loop through divs and show correct div
	
	
	function showNews () {
        news.fadeOut(0) // hide all divs
            .filter(function (index) { return index == newscounter % 3; }) // figure out correct div to show
			.slideDown('slow');
		$().css({'behavior' : 'url(/js/iepngfix.htc;'});
													   
			
        newscounter++;

    }; // 

    showDiv();
	showNews();// show first div    

    setInterval(function () {
        showDiv(); // show next div
    }, 15 * 1000); // do this every 10 seconds   
	
	setInterval(function () {
        showNews(); // show next div
    }, 8 * 1000); // do this every 10 seconds 



  // Create event listeners for .controls clicks
  $('#forward')
    .bind('click', function(){
    // Determine new position
	divs.hide();
	showDiv();
	
	
     
    });
	
	  $('#back')
    .bind('click', function(){
    // Determine new positio
	divs.hide();
	counter--;
	counter--;
	showDiv();
	
     
    });


	$('#pics a').colorbox({rel:'colorBox'})


	
  });