$(document).ready(function(){
	var newscounter = 0;
	var news = $('#newsOne, #newsTwo, #newsThree, #newsFour, #newsFive');

	
	function showNews () {
        news.fadeOut(0) // hide all divs
            .filter(function (index) { return index == newscounter % 5; }) // figure out correct div to show
			.slideDown('slow');							   
			
        newscounter++;

    } // 

	showNews();// show first div    

	
	setInterval(function () {
        showNews(); // show next div
    }, 8 * 1000); // do this every 10 seconds 
	
	var counter = 0,
    divs = $('#one, #two, #three, #four, #five, #six');
	
	function showDiv () {
        divs.fadeOut(0) // hide all divs
            .filter(function (index) { return index == counter % 6; }) // figure out correct div to show
			.fadeIn('slow');
        counter++;

    }
	
	showDiv();
	
	setInterval(function () {
        showDiv(); // show next div
    }, 15 * 1000); // do this every 10 seconds  
	
	$('#forward').bind('click', function(){
		// Determine new position
		divs.hide();
		showDiv();
    });
	
	$('#back').bind('click', function(){
		// Determine new positio
		divs.hide();
		counter--;
		counter--;
		if(counter<1) {counter = 6;}
		showDiv();
    });
	
	//about us
	var lcounter = 0;
    var divsl = $('#lone, #ltwo, #lthree, #lfour, #lfive, #lsix, #lseven, #leight, #lnine');
	
	function showDivl () {
        divsl.fadeOut(0) // hide all divs
            .filter(function (index) { return index == lcounter % 9; }) // figure out correct div to show
			.fadeIn('slow');
        lcounter++;

    }
	
	showDivl();
	
	setInterval(function () {
        showDivl(); // show next div
    }, 15 * 1000); // do this every 10 seconds  
	
	$('#lforward').bind('click', function(){
		// Determine new position
		divsl.hide();
		showDivl();
    });
	
	$('#lback').bind('click', function(){
		// Determine new position
		divsl.hide();
		lcounter--;
		lcounter--;
		if(lcounter<1){ lcounter = 5;}
		showDivl();
    });
		//fake hover with image map
	
	$("#web").hover(function(){
		 //in
		 $("#web_hover").attr('class', 'web_hover');
	}, 
	function(){
		 //out
		 $("#web_hover").attr('class', 'web');
	});
	
	$("#creative").hover(function(){
		 //in
		 $("#creative_hover").attr('class', 'creative_hover');
	}, 
	function(){
		 //out
		 $("#creative_hover").attr('class', 'creative');
	});
	
	$("#seo").hover(function(){
		 //in
		 $("#seo_hover").attr('class', 'seo_hover');
	}, 
	function(){
		 //out
		 $("#seo_hover").attr('class', 'seo');
	});
	
	$("#print").hover(function(){
		 //in
		 $("#print_hover").attr('class', 'print_hover');
	}, 
	function(){
		 //out
		 $("#print_hover").attr('class', 'print');
	});
	
	//hover menu
	
	$("#nav li").hover(
		function(){
			if($(this).children("ul").css('display')=='none') {
				$(this).children("ul").show();
			}
		},
		function(){
			$(this).children("ul").hide();
		}
	);
	
	 $("#nav li ul").hover(
		function(){
			$(this).parent().children("a").addClass('item_sel');
		},
		
		function(){
			$(this).parent().children("a").removeClass('item_sel');
		}
	);
});