jQuery(function($){
	/* Headline News */
        $headline = $('#headlinescontent li'); // List of slides , e.g: $('#divIDwrapper ul li')
        $delay = 2000; // Time delay, in miliseconds;
        $delayaft = 5000; // Time delay after clicking navigation, in miliseconds. Set '0' to disable animation
    /* All Done! Don't edit below this */
        $allheadlines = $headline.length; // Count the number of slides
        /* Begin The Show */
            var x=0; //Index of slide
            var headlineslide = function simpleslide() {
                if(x==$allheadlines){
                    x = 0; // end of slide
                } else {
                    x = ++x % $allheadlines;
                }
                $('#headlinescontent li').hide().eq(x).fadeIn();
    			$('#headlinesnav li a').removeClass().eq(x).addClass('current');
                headlinetimeout = setTimeout(headlineslide,$delay);
            };         
         /* Hovering */
             $headline.hover(function(){
                 clearTimeout(headlinetimeout);
             },function(){
                 if($delayaft!=0){headlinetimeout = setTimeout(headlineslide,$delayaft);}
             });
    headlinetimeout = setTimeout(headlineslide,$delay);// initialize!
	$('#headlinescontent li').hide().eq(0).show();
	$('#headlinesnav li a').eq(0).addClass('current');
	$('#headlinesnav li a').each(function(index){
		$(this).click(function(){
		    x = index;
		    clearTimeout(headlinetimeout);
			$('#headlinescontent li').hide().eq(index).fadeIn();
			$('#headlinesnav li a').removeClass().eq(index).addClass('current');
			headlinetimeout = setTimeout(headlineslide,$delay);
			return false;
		});
	});
	
	/* Friend */
	$('#friendcontent li').hide().eq(0).show();
	$('#friendnav li a').eq(0).addClass('current');
	$('#friendnav li a').each(function(index){
		$(this).click(function(){
			$('#friendcontent li').hide().eq(index).fadeIn();
			$('#friendnav li a').removeClass().eq(index).addClass('current');
			return false;
		});
	});
	/* Community */
	$('#communitycontent li').hide().eq(0).show();
	$('#communitynav li a').eq(0).addClass('current');
	$('#communitynav li a').each(function(index){
		$(this).click(function(){
			$('#communitycontent li').hide().eq(index).fadeIn();
			$('#communitynav li a').removeClass().eq(index).addClass('current');
			return false;
		});
	});
	/* Slider */
	/* general options, Edit information below this area: */
        $slides = 12; // Number of slides to be displayed in the slideshow
        $margin = 20; // Distance between slides
        $nav = $('#memberslidernav a'); // The Anchor for Slide navigation, e.g $('#divIDnav a')
        $div = $('#membersliderwrapper ul li'); // List of slides , e.g: $('#divIDwrapper ul li')
        $delay = 2000; // Time delay, in miliseconds;
        $delayaft = 5000; // Time delay after clicking navigation, in miliseconds. Set '0' to disable animation

    /* All Done! Don't edit below this */
        $divwidth = parseInt($div.css("width")) + $margin ; // Calculate slideshow container's width
        $divheight = parseInt($div.css("height")) + $margin; // Calculate slideshow container's height
        $alldiv = $div.length; // Count the number of slides
        $div.parent('ul').css({"width": $alldiv*$divwidth,"height": $divheight }).parent('div').css({"height": $divheight}) // Rewrite the slideshow container's dimension
        $div.each(function(index){
           $(this).css({"left" : index*$divwidth })
        }); // Make all slides distance each other
        if($alldiv<=$slides){$nav.parent('div').hide()}; // Hide navigation if insufficient slides
        /* Begin The Show */
            var i=0; //Index of slide
            var simpleslide = function simpleslide() {
                if(i==($alldiv-$slides) || 0>($alldiv-$slides) ){
                    i = 0; // end of slide
                } else {
                    i = ++i % $alldiv;
                }
                $div.parent('ul').animate({"left": i*(-1)*($divwidth)})
                timeoutslide = setTimeout(simpleslide,$delay);
            };
         /* Navigation */
            $nav.filter('.next').click(function(){
               clearTimeout(timeoutslide);
               if(i==($alldiv-$slides)){
                    i = 0; // end of slide
                } else {
                    i = ++i % $alldiv;
                }
                $div.parent('ul').animate({"left": i*(-1)*($divwidth)})
                if($delayaft!=0){timeoutslide = setTimeout(simpleslide,$delayaft);}
               return false;
            });
            $nav.filter('.previous').click(function(){
               clearTimeout(timeoutslide);
               if(i==0){
                    i = ($alldiv-$slides); // end of slide
                } else {
                    i = --i % $alldiv;
                }
                $div.parent('ul').animate({"left": i*(-1)*($divwidth)})
                if($delayaft!=0){timeoutslide = setTimeout(simpleslide,$delayaft);}
                return false;
            });
         /* Hovering */
             $div.hover(function(){
                 clearTimeout(timeoutslide);
             },function(){
                 if($delayaft!=0){timeoutslide = setTimeout(simpleslide,$delayaft);}
             });
    timeoutslide = setTimeout(simpleslide,$delay);// initialize!
    
    /* Form Focusing */
    $('.formProfile ul li').each(function(index){	
		$('.formProfile ul li').eq(index).children('input, select, textarea').focus(function() {
			$('.formProfile ul li').removeClass('focused').eq(index).addClass('focused');					   
		});	
	});
});