$(document).ready(function(){

	/**
	 * Fx for home.
	 */
	 
	if($('body#home').length){
		$('<div/>').attr('id','photobox-wrapper').insertAfter($('h2'));
		$('<div/>').attr('id','photobox').appendTo($('#photobox-wrapper'));
		$('h2').appendTo($('#photobox'));
		for(i=1;i<=5;i++){
			$('<img/>').attr('src','/images/home_ph'+i+'.jpg').attr('id','ph'+i).appendTo($('#photobox')).hide();
		}
		intervalID = setInterval( switchImage, 5000 );
	}
	
	n=1;
	switchImage(n);
	
	function switchImage(){
		if(n>5) n=1;
		$('#photobox img').each(function(){
			if($(this).attr('id') == 'ph'+n){
				$(this).fadeIn(2000);
			}else{
				$(this).fadeOut(2000);
			}
		});
		n++;
	}
	
	/**
	 * Fx for Renovation Index.
	 */
	
//	if($('body#renovation').length){
//		$('#case-studies li a').each(function(){
//			$(this).fadeTo(1000, 0.7)
//			$(this).mouseenter(function(){
//				$(this).stop();
//				$(this).fadeTo('fast', 1);
//			});
//			
//			$(this).mouseleave(function(){
//				$(this).stop();
//				$(this).fadeTo('fast',0.7);
//			});
//		});
//	}
	
	/**
	 * Fx for Photo Gallery.
	 */
	
	if($('body#photos').length){
		$('.photobox a img').each(function(){
			$(this).fadeTo(1000, 0.7)
			$(this).mouseenter(function(){
				$(this).stop();
				$(this).fadeTo('fast', 1);
			});
			
			$(this).mouseleave(function(){
				$(this).stop();
				$(this).fadeTo('fast',0.7);
			});
		});
	}
	
	/**
	 * Fx for menu.
	 */
	 
	 $('#menu-wrapper #menu li a').each(function(v){
	 	
	 	var posY = 160*v;

	 	reg = new RegExp($(this).parent().attr('id').replace('menu-',''), 'i');
	 	
	 	if(!document.URL.match(reg)){
	 		$(this).mouseenter(function(){
		 		$(this).css({
			 		'background':'url(/images/menu.png)',
			 		'background-position':'-'+posY+'px -50px'
		 		});
	 		});
	 		$(this).mouseleave(function(){
	 			$(this).css({
		 			'background':'url(/images/menu.png)',
		 			'background-position':'-'+posY+'px 0'
	 			});
	 		});
 		}else{
 			$(this).css({ 'background-position':'-'+posY+'px -100px' });
 		}
 		
 		$('body#home #menu-home a').css({'background-position':'0 -100px' });
 		$('body#home #menu-home a').unbind('mouseenter').unbind('mouseleave');
	 });
	 
	 /**
	  * Fx for pagetop.
	  */
	  
	 if($('#pagetop').length){
	 	$('#pagetop').click(function(){
	 		$(this).removeAttr('href');
	 		$('body').scrollTo($('#header'),'5000');
	 	});
	 }
	 
	 /**
	  * Fx for contact.
	  */
	  
	
});
