function flashNav(navOption){
	$("#"+navOption+"-nav").trigger('click');
}

function whereWereEating(place){
	switch(place){
		case 'HighTimber':
			var name = 'High Timber';
			var location = 'London';
			var website = 'www.hightimber.com';
			var info = "High Timber has become TXG's local for several excellent reasons. The location is perfect, down on the river just by Southwark Bridge overlooking the Tate Modern and the Globe. The wine list from their owners, the famed South African Jordan vineyard, and the food that accompanies it is always perfect. We've never had a bad meal here and then finally, there is the welcome from Neleen and the team (we'll miss you when we move Neleen!). It is rare you find a gem where you feel like part of the family.<br /><br />If you're looking for a place to eat in the City that doesn't feel too 'City', High Timber is definitely worth a visit. Biltong is at your own risk though!";
			break;
		case 'ABCKitchen':
			var name = 'ABC Kitchen';
			var location = 'New York';
			var website = 'www.abckitchennyc.com';
			var info = 'When we were in New York recently, a client recommended that we go and try ABC Kitchen if we had a chance. We tried and failed to get a table but our concierge at the Smyth Tribeca was a miracle worker and sorted it for us. We never underestimate the power of a good concierge and we will be raving about ABC Kitchen for many months to come.<br /><br />It is unassuming, joined to a home goods store (as it was closed we can only vouch for a preponderance of chandeliers!) but looks great. It is fresh, modern, friendly and welcoming and you could actually hear one another talk! The food was excellent as was the wine selection although we all agreed we had had better waiters - his opening gambit was to break a glass into our handbags which was not the best of starts! Despite that, we definitely recommend you give it a try. We went with our friend Richard who is the charming and fun CEO of a first rate event marketing company (<a href="www.firstprotocol.com" target=/"_blank">www.firstprotocol.com</a>) who chose delicious wine for us all...';
			break;
		case 'Massimo':
			var name = 'Massimo';
			var location = 'London';
			var website = 'www.massimo-restaurant.co.uk';
			var info = "We've been to Massimo twice now - once to have the informal oyster menu in the bar, and then for a full blown dinner. It's a beautiful space, with really friendly service and good quality food. It's pretty pricey, but it does feel special, which isn't always the case in London!  We'd also recommend the private dining room in the main hotel restaurant (Massimo is one of the restaurants in the newly and very decadently fitted out Corinthia hotel - the spa, which we haven't yet tried, also looked great on a quick tour around!), where they hosted a very elegant celebration dinner we went to.";
			break;
		case 'crookedWell':
			var name = 'The Crooked Well';
			var location = 'London';
			var website = 'www.thecrookedwell.com';
			var info = "Camberwell seems to have become the new Clerkenwell and this is a gastropub worth the trip - a bunch of mates have refurbished a pub and made it friendly and buzzy with a high-ceilinged dining area and a cosier bar section. The food is great (we highly recommend the roast lamb for 2 to share with tzatziki and spiced aubergine), and their house red is a cheap-as-chips but perfectly drinkable Cote du Rhone... head south of the river and try it out, just not too many of you at once - we like pretending it's our local!";
			break;
		case 'bandl':
			var name = 'Burger and Lobster';
			var location = 'London';
			var website = 'www.burgerandlobster.com';
			var info = "This is a fun new opening from the Goodman guys: no menu, 3 choices (burger, lobster roll, steamed and grilled lobster) + chips + salad for &pound;20. No bookings but you can put your name down and they call you when your table is ready (wander into a pub in Shepherd's Market whilst you wait because you will end up waiting!). When we went on Saturday it was packed and we were called for our table at 8.30pm having put our names down at 7pm. <br /><br />The room is well laid out on several levels (we had a banquet towards the back of the restaurant) and even full it wasn't too noisy. It's quick and delicious and whilst 20 quid for a burger is a bit much, 20 quid for the well-cooked lobster felt like a bargain.  Service is friendly, the house wine is passable, and they have a cocktail list which is split into 'burger' cocktails and 'lobster' cocktails...clever, huh?";
			break;
		case 'theGarrison':
			var name = 'The Garrison';
			var location = 'London';
			var website = 'www.thegarrison.co.uk';
			var info = "We were taken here for lunch by some lovely and talented colleagues we work with and it's a real find. Having always thought that part of Shad Thames a bit lacking in interesting eating choices, the Garrison is great. Interesting menu with lots of small plates as well as a few hearty main courses. Specials on a blackboard. Fresh, tasty, nothing too fancy, but well executed and with relaxed service. It's the kind of food you wish you made at home. All good so far, but the icing on the cake is that it's super-efficient! 1 1/2 hours for a 2 course lunch with coffee and we didn't feel in the tiniest bit rushed. Nice one...";
			break;
	}
	
	var content = '<div class="wwEPopupContent"><div class="wwEPopupText"><h1>'+name+'</h1><h2>'+location+'</h2><h3><a href="http://'+website+'" target="_blank">'+website+'</a></h3><p>'+info+'</p></div><div class="wwEPopupClear"></div></div>';
	
	$.fancybox({	
			'content'			: content,
        	'autoDimensions'	: true,
        	'scrolling'			: 'no',
        	'overlayColor'		: '#000',
			'width'         	: 550,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'none',
			'padding'			: 1
		}
	);	
}


function viewBiography(person){
	//Biography popups
	switch(person){
		case 'Michelle':
			var name = 'Michelle Walder';
			var jobRole = 'CEO & Co-Founder';
			var image = 'michelle-img.jpg';
			var bio = 'Michelle is one of the founders of TXG and its CEO. She studied Modern Languages and then Law in Bristol and London, before moving into the financial services sector specialising in Human Resources.  In her early career she was mostly involved in the people side of change, as she worked at Societe Generale when it purchased Hambros Bank, Commerzbank when it was establishing its global equities business, and Nomura International where her client base was the Principal Finance Group and Corporate Finance. <br /><br />Michelle moved to what had just become Dresdner Kleinwort Wasserstein where she worked with the Capital Markets business and eventually specialised in leadership and development, designing and implementing pragmatic learning and transformation tools and programmes to support the bank\'s business strategy. Michelle is trained in several coaching philosophies and methodologies, and at TXG is a key relationship contact and advisor to a number of TXG\'s clients and partners. She also delivers consulting services around change, strategy, and HR.';
			break;
		case 'Camilla':
			var name = 'Camilla Arnold';
			var jobRole = 'Global Head of Coaching';
			var image = 'camilla-img.jpg';
			var bio = 'Camilla started her career in financial services before moving into operations and marketing roles.  She has been a qualified executive coach since 1999, with a special interest in transition, behaviour change, building executive effectiveness and career development with a pragmatic, supportive, and results-orientated style.  She is a recognised expert in coaching methodologies and the global coaching market. <br /><br />At TXG, Camilla leads the vetting and matching of prospective consultants and coach for TXG client, and acts as a liaison between coaches and clients as projects and programmes develop.  She also undertakes specialist consultancy for clients on executive coaching and leadership development, and introduces or updates coaching procedures and process to highlight return on investment. Camilla is the author of \'If Not Now, When?  How to take charge of your career.\'';
			break;
		case 'Peter':
			var name = 'Peter Godfrey';
			var jobRole = 'Chairman';
			var image = 'peter-img.jpg';
			var bio = 'Peter has had a distinguished career in the financial services industry, having risen to several senior appointments at American Express and HSBC over the past twenty five years or so, latterly as President of Global Network Services and managing the fastest growing division in American Express.<br /><br />Having recently retired from American Express he has taken up several appointments and has significant personal investments in a number of businesses, both as an entrepreneur and a serial investor. In addition, he has taken on the role of director of the board at Brighton and Hove Albion football club.<br /><br />Peter is recognised as an innovator and an inspirational orator and is globally recognised for his dynamic leadership, negotiating prowess, and commitment to his team\'s professional development.';
			break;
		case 'Elizabeth':
			var name = 'Elizabeth Hammond';
			var jobRole = 'Board Advisor & Co-Founder';
			var image = 'elizabeth-img.jpg';
			var bio = 'Elizabeth was one of the co-founders of TXG and has an active role as part of our advisory team.  Elizabeth started her career at Goldman Sachs, after gaining her degree from Newcastle University, before pursuing her career in search and was the co-global head of the financial services practice at Heidrick & Struggles before founding Hammond Partners.  She is a trained high performance coach and mentor and advises a number of small businesses and entrepreneurs as a mentor and occasional angel investor. Elizabeth is on the board of my-wardrobe.com, a fast growing fashion etailer, and is a member of the Women\'s Leadership Group of The Prince\'s Trust.';
			break;
		case 'Ivan':
			var name = 'Ivan Dubovsky';
			var jobRole = 'Board Advisor';
			var image = 'ivan-img.jpg';
			var bio = 'Ivan has worked as a general manager and strategist across a broad range of large international businesses, primarily in financial services and luxury goods.  In recent years, he has held senior positions at American Express and Genworth Financial and led strategic transformation initiatives at the Royal Bank of Scotland and Vertu.  In his early career, Ivan was a consultant in the London office of McKinsey & Company; a banker and lawyer at the European Bank for Reconstruction and Development; and a lawyer at the US Department of the Treasury and the Office of the US Trade Representative.<br /><br />He holds a law degree from the Columbia University School of Law and an honours degree in Chemistry and Physics from Harvard University.  He is a shameless foodie, a keen equestrian, an aspiring photographer and a barely competent helicopter pilot.';
			break;
		case 'SJ':
			var name = 'S-J Heany';
			var jobRole = 'Office Manager';
			var image = 'sj-img.jpg';
			var bio = 'S-J is responsible for running the TXG office and our administration. Prior to joining TXG S-J has had an eclectic, creative, and rather glamorous career, the highlights of which include establishing and running her own record label, setting up and managing an acupuncture clinic, being a communications manager for a software firm, and working at and volunteering for Kids\' Company.';
			break;
	}	
	
	var content = '<div class="bioPopupContent"><div class="bioPopupImage"><img src="/images/team/'+image+'" alt="'+name+'" /></div><div class="bioPopupText"><h1>'+name+'</h1><h2>'+jobRole+'</h2><p>'+bio+'</p></div><div class="bioPopupClear"></div></div>';
	
	$.fancybox({	
			'content'			: content,
        	'autoDimensions'	: true,
        	'scrolling'			: 'no',
        	'overlayColor'		: '#000',
			'width'         	: 550,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'none',
			'padding'			: 1
		}
	);
}

jQuery(document).ready(function($){
		
	$("#michelleTip").ezpz_tooltip({contentId:"michelleInfo", stayOnContent: true, offset: 0 });
	$("#camillaTip").ezpz_tooltip({contentId:"camillaInfo", stayOnContent: true, offset: 0 });
	$("#peterTip").ezpz_tooltip({contentId:"peterInfo", stayOnContent: true, offset: 0 });
	$("#elizabethTip").ezpz_tooltip({contentId:"elizabethInfo", stayOnContent: true, offset: 0 });
	$("#ivanTip").ezpz_tooltip({contentId:"ivanInfo", stayOnContent: true, offset: 0 });
	$("#sjTip").ezpz_tooltip({contentId:"sjInfo", stayOnContent: true, offset: 0 });
		
  // Scrolling anchors: Uses jQuery + hashchange
  function scrollto ( $this )
  {	  
	  
    if ( ! $this.hash ) return ( "" );
    var $this_hash = $($this.hash);
    if ( ! $this_hash ) return ( "" );
    var $parent1 = $this_hash.closest ( '.noscroll' );
    if ( $parent1.length )
    {
      var $parent2 = $this_hash.closest ( '.scrollto' );
      if ( $parent2.length &&
           $parent2.html().length <= $parent1.html().length )
        $parent1 = "";
    }
    if ( ! $parent1.length &&
         ( location.hostname == $this.hostname || ! $this.hostname ) &&
         location.pathname.replace(/^\//,'') == $this.pathname.replace(/^\//,'') )
      return ( $this_hash );
    else
      return ( "" );
  }

  $(window).bind ( 'hashchange', function(e)
  {
    var $this = location, $this_hash = scrollto ( location );
    
   // alert('this = '+$this+' | '+$this_hash.offset().top);
    
    if ( $this_hash.length )
    {
      var duration = 1000;    // duration in ms
      var easing = 'swing';   // easing values: swing | linear

      $('html,body').animate( { scrollTop: $this_hash.offset().top-55 }, duration, easing );
    }
  });

  if ( ! $(window).scrollTop() ) $(window).trigger ( 'hashchange' );

  $('a[href*="#"]').click ( function(e)
  {
    var $this = this, $this_hash = scrollto ( this );
    // Determine applicable cases:
    if ( ! e.isDefaultPrevented() && $this_hash.length )
    {
      e.preventDefault();

      if ( location.hash == $this.hash )
      {
        // Reclick case is special:
        $(window).trigger ( 'hashchange' );
      }
      else
      {
        // Update history without scrolling:
        var hash = $this.hash.substr(1),
            dummy = $( '' ).css({
                                  visibility: 'hidden',
                                  position: 'fixed',
                                  top: '0px'
                                })
                           .attr ( 'id', hash )
                           .prependTo ( document.body );
        $this_hash.attr ( 'id', '' );
        location.hash = $this.hash;
        dummy.remove();
        $this_hash.attr ( 'id', hash );
      }
    }
  });
});

function contactTXG(){
	/**************************
	* Submit the Contact form *
	**************************/
	//setup the variables
	var cFirstName = '';
	var cLastName = '';
	var cPhoneNumber = '';
	var cEmailAddress = '';
	var cSubject = '';
	var cMessage = '';
	var formError = false;
	
	var wait = {};
	
	//get the variables
	var cFirstName = $('#sayHelloFirstname').val();
	var cLastName = $('#sayHelloSecondName').val();
	var cPhoneNumber = $('#sayHelloPhoneNumber').val();
	var cEmailAddress = $('#sayHelloEmail').val();
	var cSubject = $('#sayHelloSubject').val();
	var cMessage = $('#sayHelloMessage').val();
	
	//Validate firstname
	if(cFirstName == ''){ $('#sayHelloFirstname').css("background-position","0px -39px"); formError = true; }else{ $('#sayHelloFirstname').css("background-position","top left"); }
	//Validate lastname
	if(cLastName == ''){ $('#sayHelloSecondName').css("background-position","0px -39px"); formError = true; }else{ $('#sayHelloSecondName').css("background-position","top left"); }
	//Validate contact number
	if(cPhoneNumber == ''){ $('#sayHelloPhoneNumber').css("background-position","0px -39px"); formError = true; }else{ $('#sayHelloPhoneNumber').css("background-position","top left"); }
	//Validate email
	if(cEmailAddress == ''){ $('#sayHelloEmail').css("background-position","0px -39px"); formError = true; }else{ $('#sayHelloEmail').css("background-position","top left"); }
	//Validate subject
	if(cSubject == ''){ $('#sayHelloSubject').css("background-position","0px -39px"); formError = true; }else{ $('#sayHelloSubject').css("background-position","top left"); }
	//Validate message
	if(cMessage == ''){ $('#sayHelloMessage').css("background-position","0px -179px"); formError = true; }else{ $('#sayHelloMessage').css("background-position","top left"); }

	if(!formError){
		$('#sayHelloSendBtn').hide();
		$('#sayHelloSending').show();
		
		$.post('/jquery.php?action=contact-us',{cFirstName:cFirstName, cLastName:cLastName, cPhoneNumber:cPhoneNumber, cEmailAddress:cEmailAddress, cSubject:cSubject, cMessage:cMessage}, function(data){
				if(data.success){
					$('#sayHelloForm').fadeOut(300, function(){
						$('#sayHelloSuccess').fadeIn(300);
					});
				}else{
					//firstname error
					if(data.firstNameError){ $('#sayHelloFirstname').css("background-position","bottom left"); }else{ $('#sayHelloFirstname').css("background-position","top left"); }
					//lastname error
					if(data.lastNameError){ $('#sayHelloSecondName').css("background-position","bottom left"); }else{ $('#sayHelloSecondName').css("background-position","top left"); }
					//contact number error
					if(data.contactNoError){ $('#sayHelloPhoneNumber').css("background-position","bottom left"); }else{ $('#sayHelloPhoneNumber').css("background-position","top left"); }
					//email error
					if(data.emailError){ $('#sayHelloEmail').css("background-position","bottom left"); }else{ $('#sayHelloEmail').css("background-position","top left"); }
					//subject error
					if(data.subjectError){ $('#sayHelloSubject').css("background-position","bottom left"); }else{ $('#sayHelloSubject').css("background-position","top left"); }	
					//message error
					if(data.messageError){ $('#callBackMessage').css("background-position","bottom left"); }else{ $('#callBackMessage').css("background-position","top left"); }				
					
					$('#sayHelloSending').hide();
					$('#sayHelloSendBtn').show();
				}			
		}, 'json'); 
	}	
}
