$(function(){
	// Main pictures front, hide all
	$('.slide').hide();
	// Show the first one
	$('#one').fadeIn('slow');	

	$('.slideButton').click(function(){
		$('.slideButton').removeClass('active');
		$(this).toggleClass('active');
		var select = $(this).children("a").attr('href');
		$('.slide').hide();
		$(select).fadeIn('slow');
	});

	//Navigation slideup and hover
	$('li.parent').hover(
		function () {
			$(this).delay(100).animate({
				top:'-=50px'
			}, 
			200).children('ul.children').delay(150).fadeIn('fast')
		}, 
		function () {
			$(this).delay(200).animate({
				top:'+=50px'
			}, 
			200).children('ul.children').delay(150).fadeOut('fast');
		}
	);
	$('li.parent_small').hover(
		function () {
			$(this).delay(100).animate({
				top:'-=20px'
			}, 
			200).children('ul.children').delay(150).fadeIn('fast')
		}, 
		function () {
			$(this).delay(200).animate({
				top:'+=20px'
			}, 
			200).children('ul.children').delay(150).fadeOut('fast');
		}
	);

	$('li.parent_static').hover(
		function () {
			$(this).delay(100).animate({
				top:'-=0px'
			}, 
			200).children('ul.children').delay(150).fadeIn('fast')
		}, 
		function () {
			$(this).delay(200).animate({
				top:'+=0px'
			}, 
			200).children('ul.children').delay(150).fadeOut('fast');
		}
	);

	//Popups
	$('#e_agile_link').click(function(e){
		e.preventDefault();
		$.modal($("#e_agile"),{
			containerCss : {
				backgroundColor:"#333333", 
				border : "none",
				height : "370px",
				width : "750px"
			},
			dataCss :{
				color:"#FFF",
				width : "700px"
			}
		});
	});
	
	//Popups
	$('#agile_link').click(function(e){
		e.preventDefault();
		$.modal($("#agile"),{
			containerCss : {
				backgroundColor:"#333333", 
				border : "none",
				height : "370px",
				width : "750px"
			},
			dataCss :{
				color:"#FFF",
				width : "700px"
			}
		});	
	});
	
	//Popups
	$('#web_link').click(function(e){
		e.preventDefault();
		$.modal($("#web_window"),{
			containerCss : {
				backgroundColor:"#333333", 
				border : "none",
				height : "470px",
				width : "750px"
			},
			dataCss :{
				color:"#FFF",
				width : "700px"
			}
		});	
	});
	
	//Popups
	$('#web_link_e').click(function(e){
		e.preventDefault();
		$.modal($("#web_window_e"),{
			containerCss : {
				backgroundColor:"#333333", 
				border : "none",
				height : "470px",
				width : "750px"
			},
			dataCss :{
				color:"#FFF",
				width : "700px"
			}
		});	
	});
	
	//Management Pictures
	var pic;
	var pic2;
	$('.management_picture').hover(
		function(){
			var self = this;
			var pic2 = $(self).attr('title');
		
			if($(pic2).hasClass('laugh')){
				$(self).hide();
				$(pic2).fadeIn();
			}
		},
		function(){
			var self = this;
			if($(self).hasClass('laugh')){
				var pic2 = $(self).attr('title');
				$(self).hide();
				$(pic2).fadeIn();
			}
		}
	);
	
	//Slidedown
	$("#reduce_cost_button").click(function(e){
		e.preventDefault();
	 	var slide = $(this).attr('href')
		$(slide).slideDown();
	});
	
	$("#reduce_cost_e_button").click(function(e){
		e.preventDefault();
		var slide = $(this).attr('href')
	 	$(slide).slideDown();
	});
});
