$(document).ready(function() {
	
	$(".ref").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'type'				: 'image',
		'centerOnScroll'				: 'true',
		'overlayColor'				: '#000'
	});
	
	$('#ref_text').cycle({ 
			fx:  'fade',
			speed:   1500, 
			timeout: 5000,
			delay: -2000,
			//sync: 0,
			pause:   1,
	});
	
	$('ul#news li').css({opacity: 0.3});
	$bitch_news = false;
	$again_news = false;
	var $news_text = $('#news_text').cycle({ 
			fx:     'fade',
			speed:   1000,
			sync: 0,
			timeout: 10000,
			before: function(curr,next,opts){
				$('ul#news li').stop(true,true).animate({opacity: 0.3}, 1000, function(){});
				if($again_news==false)
				{
					if(opts.currSlide==0&&$bitch_news==false){$('ul#news li#new_'+(1)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_news = true;}
					else if(opts.currSlide==0&&$bitch_news==true){$('ul#news li#new_'+(2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_news = true;}
					else{$('ul#news li#new_'+(opts.currSlide+2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_news = false; $again_news = true;}
				}
				else
				{
					if(opts.currSlide==2){$('ul#news li#new_'+(1)).stop(true,true).animate({opacity: 1}, 1000, function(){});}
					else if(opts.currSlide==0&&$bitch_news==true){$('ul#news li#new_'+(2)).stop(true,true).animate({opacity: 1}, 1000, function(){});}
					else{$('ul#news li#new_'+(opts.currSlide+2)).stop(true,true).animate({opacity: 1}, 1000, function(){});}
				}				
			}
	});
	
	/*
	$('ul#services li').css({'backgroundColor': '#222328'});
	$('ul#services li').stop(false,false).animate({opacity: 0.3}, 0, function() {});
	$bitch_services = false;
	$again_services = false;
	var $services_text = $('#services_box').cycle({ 
			fx:     'fade', 
			speed:   1000,
			sync: 1,
			timeout: 2000, 
			before: function(curr,next,opts){
				$('ul#services li').css({'backgroundColor': '#222328'});
				$('ul#services li').stop(false,false).animate({opacity: 0.3}, 1000, function(){});
				if($again_services==false)
				{
					if(opts.currSlide==0&&$bitch_services==false){$('ul#services li#service_'+(1)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_services = true; $('ul#services li#service_'+(1)).css({'backgroundColor': '#111111'});}
					else if(opts.currSlide==0&&$bitch_services==true){$('ul#services li#service_'+(2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_services = true; $('ul#services li#service_'+(2)).css({'backgroundColor': '#111111'});}
					else{$('ul#services li#service_'+(opts.currSlide+2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $bitch_services = false; $again_services = true; $('ul#services li#service_'+(opts.currSlide+2)).css({'backgroundColor': '#111111'});}
				}
				else
				{
					if(opts.currSlide==4){$('ul#services li#service_'+(1)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $('ul#services li#service_'+(1)).css({'backgroundColor': '#111111'});}
					else if(opts.currSlide==0&&$bitch_services==true){$('ul#services li#service_'+(2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $('ul#services li#service_'+(2)).css({'backgroundColor': '#111111'});}
					else{$('ul#services li#service_'+(opts.currSlide+2)).stop(true,true).animate({opacity: 1}, 1000, function(){}); $('ul#services li#service_'+(opts.currSlide+2)).css({'backgroundColor': '#111111'});}
				}				
			}
	});
	*/
	
	if(ie==false)
	{
		$("#header_logo a").mouseenter(function(){
			$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
		});
		$("#header_logo a").mouseleave(function(){
			$(this).stop(true, true).animate({opacity: 0}, 200, function() {})
		});
	
		$("ul#subpage_submenu li a").mouseenter(function(){
			$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
		});
		$("ul#subpage_submenu li a").mouseleave(function(){
			$(this).stop(true, true).animate({opacity: 0.5}, 200, function() {})
		});	
		
		$("ul#subpage_submenu li#sublink_active a").mouseenter(function(){
			$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
		});
		
		$("ul#subpage_submenu li#sublink_active a").mouseleave(function(){
			$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
		});
	}
	
	$(".ref").css({opacity: 0.7});
	
	$(".ref").mouseenter(function(){
		$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
	});
	
	$(".ref").mouseleave(function(){
		$(this).stop(true, true).animate({opacity: 0.7}, 200, function() {})
	});
	
});
