
$(document).ready(function() {
	
	// Fancy box
	$('.fancy').fancybox();


	var activeMenu=$('.menu a.selected');

	var menuLocations=new Array();
	menuLocations['welcome']=38;
	menuLocations['what-we-do']=127;
	menuLocations['portfolio']=211;	
	menuLocations['meet-us']=284;
	menuLocations['help-and-support']=373;
	menuLocations['quotation']=468;
	menuLocations['contact-us']=550;
		
	var arrowDefault=menuLocations[activeMenu.attr('id')];
	
	$('.arrow').show().animate( {'left': (arrowDefault)+"px" },500,function() {		
		activeMenu.animate( { 'top': '-10px'},100,function() {
			$(this).animate( { 'top': '0px'},150);
		})
	});
	
	$('#submenu a').each(function() {
		$(this).hover(function() {
			$(this).animate({ paddingLeft: '5px' },100);
		},function() {
			$(this).animate({ paddingLeft: '0px' },100);
		});
	});

	$('.cleardefault').focus(function() {
		var def=$(this).attr('name');
		
		var defex=def.split("");
		def=defex[0].toUpperCase();
		delete defex[0];
		def=def + defex.join("");
		
		if(this.value == def) {
			this.value='';
		}
	});
	
	$('.cleardefault').blur(function() {
		var def=$(this).attr('name');
		
		var defex=def.split("");
		def=defex[0].toUpperCase();
		delete defex[0];
		def=def + defex.join("");
		
		if(this.value == '') {
			this.value=def;
		}
	});


	$('.menu a').hover(function() {
		var link=$(this);
		//alert('hello');
		$('.arrow').stop(true,false).animate( { 'left': menuLocations[link.attr('id')]+"px" } , { queue: false, duration: 200 });
	},function() {
		$('.arrow').animate({opacity: "1.0"},800).animate( { 'left': arrowDefault+"px" }, { queue: true, duration: 200 });
	});
	
	
	
	/* Portfolio */
	
	$('.thumbgrid img.zoomer').each(function() {

		switch($(this).attr('rel')) {
			case 'se':
				$(this).css('left','0px').css('top','0');
			break;
			case 'sw':
				$(this).css('top','0').css('right','0');
			break;
			case 'nw':
				$(this).css('right','0').css('bottom','0');
			break;
			case 'ne':
				$(this).css('left','0px').css('bottom','0');
			break;
		}
		
		//$('.thumbgrid img.zoomer[rel="sw"]').css('left','-1px');
		
		$(this).hoverIntent(function() {
			
			$('.thumbgrid img.zoomer').css('zIndex','0');
			
			$(this).parent('a').parent('div').css('zIndex','10');
			$(this).attr('src',$(this).siblings('.preloader').attr('src')).css('opacity','1').animate({ width: "330px", height: "330px", borderWidth: "10px" });
			
			
		},function() {
			//$('.thumbgrid img').css('opacity','1');
			$(this).attr('src',$(this).siblings('.preloader').attr('original')).animate( { width: "180px", height: "180px", borderWidth: "1px" }, 300, function() { 
				$(this).parent('a').parent('div').css('zIndex','0'); 
			});

		});
		
	})
	
		
});