function mainmenu(){
$("#nav ul ul").css({display: "none"}); 
$("#nav ul ul ul").css({display: "block"}); 
$("#nav ul li").hover(function(){
	$(this).find('ul:first').parent('li').addClass("dropdown");
	if($(this).parent('ul').parent('li').hasClass('dropdown')) {
		$('#nav ul ul ul').show();
	} else {
		$(this).find('ul:first').fadeIn(300);
	}
},function(){
	$(this).find('ul:first').hide();
	$("#nav ul ul ul").css({display: "block"});
	$(this).find('ul:first').parent('li').removeClass("dropdown");
});
}


$(function() {

	
// Header Login
	var headerlogin = 0;
	$('#header .login .handle').click(function() {
		if(headerlogin == 0) {
			headerlogin = 1;
			$(this).find('.arrow').fadeOut(500);
			$(this).parent('.login').animate({"top":"0px"}, 500);
		} else {
			headerlogin = 0;
			$(this).find('.arrow').fadeIn(500);
			$(this).parent('.login').animate({"top":"-282px"}, 500);
		}
		return false;
	});
	

// Header Dropdown
	var headerdropdown = 0;
	$('#header .dropdown .handle').click(function() {
		if(headerdropdown == 0) {
			headerdropdown = 1;
			$(this).find('span.red').find('.arrow').fadeOut(500);
			$(this).find('span.red').find('.arrowup').fadeIn(500);
			$(this).parent('.dropdown').find('.hidden').slideDown(500);
		} else {
			headerdropdown = 0;
			$(this).find('span.red').find('.arrow').fadeOut(500);
			$(this).find('span.red').find('.arrowdown').fadeIn(500);
			$(this).parent('.dropdown').find('.hidden').slideUp(500);
		}
		return false;
	});
	

// Menu
	mainmenu();
	$('#nav li:last').addClass('last');	


// Subscribe Widget
	$('#sidebar .subscribewidget ul li').hover(function() {
		$('#sidebar .subscribewidget p span').text($(this).find('a').attr('title'));
	});


/* / Region Subpages
	$('.regionpost .regionsubpages li').each(function() {
		$(this).find('a').prepend('<span>Skip Hire </span>');
	});
	*/

// Contact Form
	$('form .name input').focus(function() {
		if($(this).attr("value") == "Name*") { $(this).attr("value",""); }
	});
	$('form .name input').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","Name*"); }
	});
	
	$('form .email input').focus(function() {
		if($(this).attr("value") == "Email address*") { $(this).attr("value",""); }
	});
	$('form .email input').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","Email address*"); }
	});
	
	$('form .company input').focus(function() {
		if($(this).attr("value") == "Company") { $(this).attr("value",""); }
	});
	$('form .company input').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","Company"); }
	});
	
	$('form .phone input').focus(function() {
		if($(this).attr("value") == "Phone number") { $(this).attr("value",""); }
	});
	$('form .phone input').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","Phone number"); }
	});
	
	$('form .comments textarea').focus(function() {
		if($(this).attr("value") == "Your comments...") { $(this).attr("value",""); }
	});
	$('form .comments textarea').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","Your comments..."); }
	});
	
$('.team .thumbs ul li').hoverIntent(function() {
		$(this).find('p').fadeIn();
	}, function() {
		$(this).find('p').fadeOut();
	});
	
	var currentprofile = 0;
	$('.team .thumbs ul li').click(function() {
		currentprofile = $('.team .thumbs ul li').index($(this));
		$('.profiles .profile').hide();
		$('.profiles .profile').eq(currentprofile).fadeIn();
	});
	
	var numberofprofiles = $('.team .thumbs li').size();
	var currentprofileslide = 0;
	var newlocation = 0;
	var numberofprofileslides = Math.round(numberofprofiles / 4);
	$('.team .arrowright').click(function() {
		currentprofileslide++;
		if(currentprofileslide >= numberofprofileslides+1) { currentprofileslide = numberofprofileslides; } else {
		newlocation = currentprofileslide * 154 *4;
		newlocation = newlocation - newlocation - newlocation;
		$('.team .thumbs').animate({"left":newlocation});
		}
		return false;
	});
	$('.team .arrowleft').click(function() {
		currentprofileslide = currentprofileslide - 1;
		if(currentprofileslide <= -1) { currentprofileslide = 0; } else {
		newlocation = currentprofileslide * 154 *4;
		newlocation = newlocation - newlocation - newlocation;
		$('.team .thumbs').animate({"left":newlocation});
		}
		return false;
	});
	
	$('.team .arrow').hover(function() {
		$(this).animate({"opacity":"1"});
	}, function() {
		$(this).animate({"opacity":"0.6"});	
	});
	
	$('#home_footer .left .latest_news_circles li').click(function() {
		$('#home_footer .left .latest_news_circles li').removeClass('active');
		$(this).addClass('active');
		$('#home_footer .left .latest_news_posts li').hide();
	});
	$('#home_footer .left .latest_news_circles li').eq(0).click(function() { $('#home_footer .left .latest_news_posts li').eq(0).fadeIn(); });
	$('#home_footer .left .latest_news_circles li').eq(1).click(function() { $('#home_footer .left .latest_news_posts li').eq(1).fadeIn(); });
	$('#home_footer .left .latest_news_circles li').eq(2).click(function() { $('#home_footer .left .latest_news_posts li').eq(2).fadeIn(); });
	
});

$(window).load(function() {
	$('#subfooter .testimonial a.testimoniallink span.text').css({"top" : (jQuery('#subfooter .testimonial a.testimoniallink img').height() - jQuery('#subfooter .testimonial a.testimoniallink span.text').height()) / 2 });
});
