// services Slider
$slideshow = {
    context: false,
    tabs: false,
    timeout: 10000,
    slideSpeed: 1000,
    tabSpeed: 500,
    fx: 'scrollRight',    
    init: function() {
        this.context = $('#services_slider');
        this.tabs = $('ul.slides-nav li', this.context);
        this.tabs.remove();
        this.prepareSlideshow();
    },    
    prepareSlideshow: function() {
        $('div.slides > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
            timeout: $slideshow.timeout,
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            pager: $('ul.slides-nav', $slideshow.context),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },    
    prepareTabs: function(i, slide) {
        return $slideshow.tabs.eq(i);
    },
    activateTab: function(currentSlide, nextSlide) {
        var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context);
        if(activeTab.length) {
            $slideshow.tabs.removeClass('on');            
            activeTab.parent().addClass('on');
        }            
    }            
};
$(function(){
    $('body').addClass('js');    
    $slideshow.init();
});

$(function(){
	$("#services_slider .slides ul li").click(function(){
		theURL = $(this).attr("rel");
		window.location=theURL;
	});
});

// R&D 1 Hover
$(function(){
	$(".latest_rd_1").hover(function(){
		$(".latest_rd_1_hover").fadeIn(300);
		$(".latest_rd_1>h5").fadeOut(500);
		
	}, function() {
		$(".latest_rd_1_hover").fadeOut(300);
		$(".latest_rd_1>h5").fadeIn(200);
	});
});

// R&D 2 Hover
$(function(){
	$(".latest_rd_2").hover(function(){
		$(".latest_rd_2_hover").fadeIn(300);
		$(".latest_rd_2>h5").fadeOut(500);
		
	}, function() {
		$(".latest_rd_2_hover").fadeOut(300);
		$(".latest_rd_2>h5").fadeIn(200);
	});
});

// R&D 3 Hover
$(function(){
	$(".latest_rd_3").hover(function(){
		$(".latest_rd_3_hover").fadeIn(300);
		$(".latest_rd_3>h5").fadeOut(500);
		
	}, function() {
		$(".latest_rd_3_hover").fadeOut(300);
		$(".latest_rd_3>h5").fadeIn(200);
	});
});

// Sidebar Categories
//jQuery('.cats').accordion({ 
//    autoheight: true 
//});

// Elastic comment form textarea
$(function() {
	$('.contacttextarea').elastic();	
});

// Comment form textarea hide
$(function() {
	$("#comment").click(function(){ $(this).text("") })
});
