function ChangeFrame(elem){
	if(!elem){
		elem=$("a[rel='alert-slide'].active").next("a[rel='alert-slide']");
		if(elem.length<=0) elem=$("a[rel='alert-slide']:first");
	}	
	
	if (elem) {
		
	$("a[rel='alert-slide']").removeClass("active");
    elem.addClass("active");
    $(".alert-slide").hide();
	
	$("#" + elem.attr("id") + "-slide").fadeIn('fast');
    
	}
}


$(function() {
	
	var ti=window.setInterval(function(){
		ChangeFrame();
	}, 4000);
	
    $("a[rel='alert-slide']").click(function(){
    	window.clearInterval(ti);
        ChangeFrame($(this));      
        return false;
    });
	
});
	

$(function() {
	
	$("a[rel='shownext']").click(function() {
	
		var source = $($(this).attr("href"));
		
		source.find(".active").hide().removeClass("active").next("div.hidden").addClass("active").show();
		
		if (!source.find(".active").size()) {
			source.find("div:first").addClass("active").show();
		}
		
		return false;
	
	});
	
	
/*	
	$("a[rel='alert-slide']").click(function() {
	
		$(".alert-slide").hide();
		
		$("#" + $(this).attr("id") + "-slide").fadeIn('fast');
		
		return false;
	
	});
*/	
	
	
	$(".with-title").hover(function() {
	
		$(this).find(".title").fadeIn('fast');
		
	}, 
	function() {
	
		$(this).find(".title").fadeOut('fast');
		
	});
	
});



window.onload = function(){ 

	var images = $("a.best-client img");
	grayscale(images);
	images.show();

};

$(function() {
	$("a.best-client img").hide();
	$("a.best-client img").hover(function() {grayscale.reset(this);}, function() {grayscale(this);});

});
		

$(function() {
	$(".toggle_button").click(function(event){
		$(this).toggleClass("closed").next(".toggle_text").toggle();
		return false;
	}).filter(".closed").next(".toggle_text").hide();
	
	$(".openclose").click(function(){
		$(this).toggleClass("closed");
		$($(this).attr("href")).toggle();
		return false;
	});	
});
