$(document).ready(function(){

	//Slide up the notification div after 3 seconds
	$('.notification').delay(3000).slideUp();
	
	$('#currentLanguage').hover(function(){
		
		$('.additionalLanguages').fadeIn();
		
	});
	
	$('.additionalLanguages').mouseout(function(){
		
		$('.additionalLanguages').fadeOut();
		
	});
	
	//START Contact us switching//////////////////////////////////////////////////////////////////////////////////////////////
	
	//Se the variables
	var youtubeURL = $('#youtubeEmbed').attr('src');
	var currentContactCaption = $('#contactCaption').html();
	var currentContactTitle = $('#video-caption').html();
	var currentMapLink = $('#googleMapSwitcher').html();
	var youtubeIframe = '<iframe id="youtubeEmbed" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+youtubeURL+'" frameborder="0" allowfullscreen></iframe>';

	//When the switcher is clicked do:
	$('#googleMapSwitcher').click(function(){
		
		//Set the variables
		var googleMapURL = '<iframe id="googlemapEmbed" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=212864102953417612346.0004585b8cafd7568a774&amp;ll=51.553257,-0.144805&amp;spn=48.555061,135.263672&amp;output=embed"></iframe>';
		var googleMapURLUAE = '<iframe id="googlemapEmbedUAE" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=212864102953417612346.00045eb8b1cec07c1b3f5&amp;ie=UTF8&amp;ll=25.257272,55.330238&amp;spn=0,0&amp;vpsrc=6&amp;output=embed"></iframe>';
		var googleMapURLPT = '<iframe id="googlemapEmbedPT" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;ll=39.037418,-9.369132&amp;spn=48.688845,135.263672&amp;msid=212864102953417612346.0004a4810b03a441aa7a1&amp;output=embed"></iframe>';

		//If the showing attribute is youtube switch the googlemaps otherwise switch to youtube
		if($('#googleMapSwitcher').attr('showing') == 'youtube')
		{
		
			$('#youtubeEmbed').remove();
			$('#embedCode').html(googleMapURLUAE);
			$('#googleMapSwitcher').attr('showing', 'googleMap');
			$('#contactCaption').html('Map');
			$('#video-caption').html('Google map of the MintTwist London office and local area');
			$('#googleMapSwitcher').html('View video directions from Kentish Town');
		
		}
		else
		{
		
			$('#googlemapEmbed').remove();
			$('#embedCode').html(youtubeIframe);
			$('#googleMapSwitcher').attr('showing', 'youtube');
			$('#contactCaption').html(currentContactCaption);
			$('#video-caption').html(currentContactTitle);
			$('#googleMapSwitcher').html(currentMapLink);
		
		}
	
	});
	
	//END Contact us switching//////////////////////////////////////////////////////////////////////////////////////////////
	
	//START Portfolio filters//////////////////////////////////////////////////////////////////////////////////////////////
	
	var date = $('#filterDateAdded').val();
	var type = $('#filterType').val();
	var sector = $('#filterSector').val();
	var tag = $('#currentTag').val();
	
	if(sector != '')
	{
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date=&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('#portfolio-view').html(result);
			}
		});
		
		var currentSector = sector;
		var currentType = type;
		var currentDate = date;
		
		$('#dateFilterContainer').html('');
		
		filterType(currentSector, 'Sector', currentType);
		filterDate(currentSector, currentType);
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=portfolioPagination()&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('.portfolio-pagination-container').html(result);
			}
		});
	
	}
	
	if(type != '')
	{
	
		var date = $('#filterDateAdded').val();
		var type = $('#filterType').val();
		var sector = $('#filterSector').val();
		var tag = $('#currentTag').val();
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date=&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('#portfolio-view').html(result);
			}
		});
	
	}

	$('#filter-button').click(function(){
	
		var date = '';
		var type = '';
		var sector = '';
		var tag = $('#currentTag').val();
		$('#inContextSearch').val($('#inContextSearch').attr('title'));
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date="+date+"&type="+type+"&sector="+sector, 
			success: function(result){
				$('#portfolio-view').html(result)
			}
		});
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=portfolioPagination()&date="+date+"&type="+type+"&sector="+sector, 
			success: function(result){
				$('.portfolio-pagination-container').html(result);
			}
		});
		
		$('.portfolio-filter select option').attr('selected', '');
		$('.selectedoption').attr('selected', 'selected');
		 
	});

	$('#filterSector').change(function(){
	
		var date = $('#filterDateAdded').val();
		var type = $('#filterType').val();
		var sector = $('#filterSector').val();
		var tag = $('#currentTag').val();
		$('#inContextSearch').val($('#inContextSearch').attr('title'));
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date=&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('#portfolio-view').html(result);
			}
		});
		
		var currentSector = sector;
		var currentType = type;
		var currentDate = date;
		
		$('#dateFilterContainer').html('');
		
		filterType(currentSector, 'Sector', currentType);
		filterDate(currentSector, currentType);
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=portfolioPagination()&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('.portfolio-pagination-container').html(result);
			}
		});
				
	});
	
	$('#inContextSearch').keyup(function(){
	
		var inContextSearch = $('#inContextSearch').val();
	
		if(inContextSearch  != 'Filter by keyword or' || inContextSearch != '')
		{
		
			$('#filterDateAdded').val('');
			$('#filterType').val('');
			$('#filterSector').val('');
			$('#currentTag').val('');
	
			$.ajax({
				url: "/_php/ajax/functions.php?f=inContextSearch()&value="+inContextSearch, 
				success: function(result){
					$('#portfolio-view').html(result);
				}
			});
		
		}
	
	});

	$('#filterType').change(function(){
	
		var date = $('#filterDateAdded').val();
		var type = $('#filterType').val();
		var sector = $('#filterSector').val();
		var tag = $('#currentTag').val();
		$('#inContextSearch').val($('#inContextSearch').attr('title'));
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date=&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('#portfolio-view').html(result);
			}
		});
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=portfolioPagination()&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('.portfolio-pagination-container').html(result);
			}
		});
		
		var currentSector = sector;
		var currentType = type;
		var currentDate = date;
		
		filterDate(currentSector, currentType);
				
	});

	$('#filterDateAdded').change(function(){
	
		var date = $('#filterDateAdded').val();
		var type = $('#filterType').val();
		var sector = $('#filterSector').val();
		var tag = $('#currentTag').val();
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=getPortfolio()&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('#portfolio-view').html(result);
			}
		});
	
		$.ajax({
			url: "/_php/ajax/functions.php?f=portfolioPagination()&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
			success: function(result){
				$('.portfolio-pagination-container').html(result);
			}
		});
		
		var currentSector = sector;
		var currentType = type;
		var currentDate = date;
		
		if(currentDate != '')
		{
		
			filterType(currentSector, 'Sector', currentType);
		
		}
		
	});
	
	//END Portfolio filters//////////////////////////////////////////////////////////////////////////////////////////////
	
	//START Homepage banner functions//////////////////////////////////////////////////////////////////////////////////////////////
	
	//Banner rotation
	
	function rotateBanners()
	{
	
		banner1 = $("#banner-slide-1");
		banner2 = $("#banner-slide-2");
		banner3 = $("#banner-slide-3");
		banner4 = $("#banner-slide-4");
		banner5 = $("#banner-slide-5");
		delay = 6000;
		
		if(banner2.length == 1)
		{
		
			if(banner2)
		
			//Switch from banner 1 to 2
			setTimeout(function(){
				banner1.hide(0, banner2.show());
				banner3.hide(0, banner2.show());
				banner4.hide(0, banner2.show());
				banner5.hide(0, banner2.show());
				$("#reveal-banner-1").removeClass("active");
				$("#reveal-banner-2").addClass("active");
				
				if(banner3.length == 1)
				{
				
					//Switch from banner 2 to 3
					setTimeout(function(){
						banner1.hide(0, banner3.show());
						banner2.hide(0, banner3.show());
						banner4.hide(0, banner3.show());
						banner5.hide(0, banner3.show());
						$(".reveal-banner").removeClass("active");
						$("#reveal-banner-3").addClass("active");
				
						if(banner4.length == 1)
						{
						
							//Switch from banner 3 to 4
							setTimeout(function(){
								banner1.hide(0, banner4.show());
								banner2.hide(0, banner4.show());
								banner3.hide(0, banner4.show());
								banner5.hide(0, banner4.show());
								$(".reveal-banner").removeClass("active");
								$("#reveal-banner-4").addClass("active");
						
								if(banner4.length == 1)
								{
								
									//Switch from banner 4 to 5
									setTimeout(function(){
										banner1.hide(0, banner5.show());
										banner2.hide(0, banner5.show());
										banner3.hide(0, banner5.show());
										banner4.hide(0, banner5.show());
										$(".reveal-banner").removeClass("active");
										$("#reveal-banner-5").addClass("active");
						
										if(banner5.length == 1)
										{
										
											//Switch from banner 5 to 1
											setTimeout(function(){
												banner5.hide(0, banner1.show());
												$(".reveal-banner").removeClass("active");
												$("#reveal-banner-1").addClass("active");
											}, delay);
											
											//Switch Active tab
										
										}
										
									}, delay);
									
									//Switch Active tab
								
								}
								
							}, delay);
							
							//Switch Active tab
						
						}
							
					}, delay);
					
					//Switch Active tab
				
				}
				
			}, delay);
			
			//Switch Active tab
		
		}
		
		//End banner rotation
	
	} 
	
	rotateBanners();
	
	totalBannerTime = 30000;
	
	intervalID = setInterval(function(){rotateBanners();}, totalBannerTime);
	
	$("#reveal-banner-1").click(function () {
		$("#banner-slide-1").fadeIn();
		$("#banner-slide-2").hide();
		$("#banner-slide-3").hide();
		$("#banner-slide-4").hide();
		$("#banner-slide-5").hide();
		
		$(this).addClass("active");
		$("#reveal-banner-4").removeClass("active");
		$("#reveal-banner-3").removeClass("active");
		$("#reveal-banner-2").removeClass("active");
		$("#reveal-banner-5").removeClass("active");
		
		clearInterval(intervalID);
		
		return false;
	});
	
	$("#reveal-banner-2").click(function () {
		$("#banner-slide-1").hide();
		$("#banner-slide-2").fadeIn();
		$("#banner-slide-3").hide();
		$("#banner-slide-4").hide();
		$("#banner-slide-5").hide();
		
		$(this).addClass("active");
		$("#reveal-banner-4").removeClass("active");
		$("#reveal-banner-3").removeClass("active");
		$("#reveal-banner-5").removeClass("active");
		$("#reveal-banner-1").removeClass("active");
		
		clearInterval(intervalID);
		
		return false;
	});
	
	$("#reveal-banner-3").click(function () {
		$("#banner-slide-1").hide();
		$("#banner-slide-2").hide();
		$("#banner-slide-3").fadeIn();
		$("#banner-slide-4").hide();
		$("#banner-slide-5").hide();
		
		$(this).addClass("active");
		$("#reveal-banner-4").removeClass("active");
		$("#reveal-banner-5").removeClass("active");
		$("#reveal-banner-2").removeClass("active");
		$("#reveal-banner-1").removeClass("active");
		
		clearInterval(intervalID);
		
		return false;
	});
	
	$("#reveal-banner-4").click(function () {
		$("#banner-slide-1").hide();
		$("#banner-slide-2").hide();
		$("#banner-slide-3").hide();
		$("#banner-slide-4").fadeIn();
		$("#banner-slide-5").hide();
		
		$(this).addClass("active");
		$("#reveal-banner-5").removeClass("active");
		$("#reveal-banner-3").removeClass("active");
		$("#reveal-banner-2").removeClass("active");
		$("#reveal-banner-1").removeClass("active");
		
		clearInterval(intervalID);
		
		return false;
	});
	
	$("#reveal-banner-5").click(function () {
		
		$("#banner-slide-1").hide();
		$("#banner-slide-2").hide();
		$("#banner-slide-3").hide();
		$("#banner-slide-4").hide();
		$("#banner-slide-5").fadeIn();
		
		$(this).addClass("active");
		$("#reveal-banner-4").removeClass("active");
		$("#reveal-banner-3").removeClass("active");
		$("#reveal-banner-2").removeClass("active");
		$("#reveal-banner-1").removeClass("active");
		
		clearInterval(intervalID);
		
		return false;
	});

	//Home page tab functions

	$("#tab-content-1").show();
	$("#tab-content-2").hide();
	$("#tab-content-3").hide();
	$("#tab-content-4").hide();
	$("#tab-content-5").hide();
	
	$("#reveal-tab-1").click(function () {
		$(".tab-buttons a").removeClass('active');
		$("#reveal-tab-1").addClass('active');
		$("#tab-content-1").fadeIn();
		$("#tab-content-2").hide();
		$("#tab-content-3").hide();
		$("#tab-content-4").hide();
		$("#tab-content-5").hide();
		return false;
	});
	
	$("#reveal-tab-2").click(function () {
		$(".tab-buttons a").removeClass('active');
		$("#reveal-tab-2").addClass('active');
		$("#tab-content-1").hide();
		$("#tab-content-2").fadeIn();
		$("#tab-content-3").hide();
		$("#tab-content-4").hide();
		$("#tab-content-5").hide();
		return false;
	});
	
	$("#reveal-tab-3").click(function () {
		$(".tab-buttons a").removeClass('active');
		$("#reveal-tab-3").addClass('active');
		$("#tab-content-1").hide();
		$("#tab-content-2").hide();
		$("#tab-content-3").fadeIn();
		$("#tab-content-4").hide();
		$("#tab-content-5").hide();
		return false;
	});
	
	$("#reveal-tab-4").click(function () {
		$(".tab-buttons a").removeClass('active');
		$("#reveal-tab-4").addClass('active');
		$("#tab-content-1").hide();
		$("#tab-content-2").hide();
		$("#tab-content-3").hide();
		$("#tab-content-4").fadeIn();
		$("#tab-content-5").hide();
		return false;
	});
	
	$("#reveal-tab-5").click(function () {
		$(".tab-buttons a").removeClass('active');
		$("#reveal-tab-5").addClass('active');
		$("#tab-content-1").hide();
		$("#tab-content-2").hide();
		$("#tab-content-3").hide();
		$("#tab-content-4").hide();
		$("#tab-content-5").fadeIn();
		return false;
	});
	
	//END Homepage banner functions//////////////////////////////////////////////////////////////////////////////////////////////

	// Share MintTwist functions
	
	$("#share-minttwist").hide();
	
	$(".heading-icon.share").click(function () {
		$("#share-minttwist").fadeToggle();
		return false;
	});
	




	$('.control-up').click(function () {
		scroll = $('.screen-content').scrollTop();
		scroll2 = $('.image-container').scrollTop();
		
		$('.screen-content').animate({'scrollTop': scroll-200},1000);
		$('.image-container').animate({'scrollTop': scroll-200},1000);
		return false;
	});
	$('.control-down').click(function () {
		scroll = $('.screen-content').scrollTop();
		scroll2 = $('.image-container').scrollTop();
		
		$('.screen-content').animate({'scrollTop': scroll+200},1000);
		$('.image-container').animate({'scrollTop': scroll+200},1000);
		return false;
	});
	
	$('.control-off').click(function(){
	
		
		if($('#banner-image').length == 1)
		{
	
			$('#banner-image').remove();
	
			var on = '<img id="banner-image-on" caption="" class="banner-image show" src="/mediaLibrary/gif/c2NyZWVub24uZ2lmMTEwNTA1MTIyNTI2.gif" style="display: inline; ">';
			$('.image-container').prepend(on);
		
		}
		else
		{
		
			$('#banner-image-on').remove();
	
			var off = '<img id="banner-image" caption="" class="banner-image show" src="/mediaLibrary/gif/bm9pc2UuZ2lmMTEwNTA2MDQzMTU0.gif" style="display: inline; ">';
			$('.image-container').prepend(off);
		
		}
	
	});
	
	$('#submitRequest').click(function(){
	
		var messages = '';
		var newMessage = '';
	
		if($('#name').val() == '')
		{
		
			newMessage = 'Please enter your name\n';
			messages = messages + newMessage;
			$('#name').addClass('error');
		
		}
		else
		{
			
			$('#name').removeClass('error');
		
		}
	
		if($('#email').val() == '')
		{
		
			newMessage = 'Please a valid email address\n';
			messages = messages + newMessage;
			$('#email').addClass('error');
		
		}
		else
		{
		
			if(validateEmail($('#email').val()) == false)
			{
			
				newMessage = 'Please a valid email address\n';
				messages = messages + newMessage;
				$('#email').addClass('error');
			
			}
			else
			{
			
				$('#email').removeClass('error');
			
			}
		
		}
	
		if($('#contact').val() == '')
		{
		
			newMessage = 'Please enter your contact number\n';
			messages = messages + newMessage;
			$('#contact').addClass('error');
		
		}
		else
		{
		
			value = $('#contact').val();
			
			if(IsNumeric(value) == false)
			{
		
				newMessage = 'Please enter your contact number\n';
				messages = messages + newMessage;
				$('#contact').addClass('error');
				
			}
			else
			{
			
				$('#contact').removeClass('error');
			
			}
		
		}
	
		if($('#meetingDate').val() == '')
		{
		
			newMessage = 'Please enter a meeting date\n';
			messages = messages + newMessage;
			$('#meetingDate').addClass('error');
		
		}
		else
		{
		
			value = $('#meetingDate').val();
			weekday = value.split(' ');
			weekdays = Array(
				'Monday',
				'Tuesday',
				'Wednesday',
				'Thursday',
				'Friday',
				'Saturday',
				'Sunday'
			);
			
			if(jQuery.inArray(weekday[0], weekdays) == '-1')
			{
		
				newMessage = 'Please enter a valid meeting date\n';
				messages = messages + newMessage;
				$('#meetingDate').addClass('error');
			
			}
			else
			{
			
				$('#meetingDate').removeClass('error');
			
			}
		
		}
	
		if($('#topic').val() == '')
		{
		
			newMessage = 'Please enter a discussion topic\n';
			messages = messages + newMessage;
			$('#topic').addClass('error');
		
		}
		else
		{
			
			$('#topic').removeClass('error');
		
		}
		
		if(messages != '')
		{
		
			alert(messages);
			return false;
		
		}
	
	});
	
	function IsNumeric(sText)
	{
	
	   var ValidChars = "0123456789.+() ";
	   var IsNumber=true;
	   var Char;
	 
	   for(i = 0; i < sText.length && IsNumber == true; i++) 
	   { 
	   
	      Char = sText.charAt(i); 
	      
	      if(ValidChars.indexOf(Char) == -1) 
	      {
	      
	         IsNumber = false;
	         
	      }
	      
	   }
	   
	   return IsNumber;
	   
	}
	
	function validateEmail(elementValue)
	{  
	
	   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	   
	   return emailPattern.test(elementValue);  
	   
 	}  
	
	$('#click-2020').click(function(){
	
		$('#show-2020').slideToggle();
	
	});
	
	$('#click-2019').click(function(){
	
		$('#show-2019').slideToggle();
	
	});
	
	$('#click-2018').click(function(){
	
		$('#show-2018').slideToggle();
	
	});
	
	$('#click-2017').click(function(){
	
		$('#show-2017').slideToggle();
	
	});
	
	$('#click-2016').click(function(){
	
		$('#show-2016').slideToggle();
	
	});
	
	$('#click-2015').click(function(){
	
		$('#show-2015').slideToggle();
	
	});
	
	$('#click-2014').click(function(){
	
		$('#show-2014').slideToggle();
	
	});
	
	$('#click-2014').click(function(){
	
		$('#show-2014').slideToggle();
	
	});
	
	$('#click-2013').click(function(){
	
		$('#show-2013').slideToggle();
	
	});
	
	$('#click-2012').click(function(){
	
		$('#show-2012').slideToggle();
	
	});
	
	$('#click-2011').click(function(){
	
		$('#show-2011').slideToggle();
	
	});
	
	$('#click-2010').click(function(){
	
		$('#show-2010').slideToggle();
	
	});
	
	$('#click-2009').click(function(){
	
		$('#show-2009').slideToggle();
	
	});
	
	$('#click-2008').click(function(){
	
		$('#show-2008').slideToggle();
	
	});
	
	$('#click-2007').click(function(){
	
		$('#show-2007').slideToggle();
	
	});
	
	$('#click-2006').click(function(){
	
		$('#show-2006').slideToggle();
	
	});
	
	$('#click-2005').click(function(){
	
		$('#show-2005').slideToggle();
	
	});
	
}); // Document ready function ends 

function randomString(length) 
{

	var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
	var str = '';
	
	for(var i = 0; i < length; i++) 
	{
		str += chars[Math.floor(Math.random() * chars.length)];
	}
	
	return str;
	
}

var rnd = randomString(8);function filterType(ID, lookupName, currentType)
{
	//Filters type options on portfolio
	
	//Get the tag
	var tag = $('#currentTag').val();
	
	//Perform the request
	$.ajax({
		url: "/_php/ajax/functions.php?f=filterType()&ID="+ID+"&lookup="+lookupName+"&currentType="+currentType+"&key=tag&val="+tag, 
		success: function(result){
			$('#typeFilters').html(result)
		}
	});

}

function filterDate(sector, type)
{

	//Filters the date options on the portfolio
	var tag = $('#currentTag').val();
	
	//Perform the request
	$.ajax({
		url: "/_php/ajax/functions.php?f=filterDate()&sector="+sector+"&type="+type+"&key=tag&val="+tag, 
		success: function(result){
			$('#dateFilterContainer').html(result)
		}
	});

}

function goToPage(pageNumber)
{
	
	//Sets the page on the portfolio depending what pagination link is clicked
	
	//Set the variables
	var date = $('#filterDateAdded').val();
	var type = $('#filterType').val();
	var sector = $('#filterSector').val();
	var tag = $('#currentTag').val();
	
	
	//Perform the request for the content
	$.ajax({
		url: "/_php/ajax/functions.php?f=getPortfolio()&pageNumber="+pageNumber+"&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
		success: function(result){
			$('#portfolio-view').html(result);
		}
	});

	//Perform the request for the pagination
	$.ajax({
		url: "/_php/ajax/functions.php?f=portfolioPagination()&pageNumber="+pageNumber+"&date="+date+"&type="+type+"&sector="+sector+"&key=tag&val="+tag, 
		success: function(result){
			$('.portfolio-pagination-container').html(result);
		}
	});

}

function showPreviousBanner()
{

	//Next image number ID
	var previousImage = $('#control-left').attr('previous');
	
	//Next image html ID
	var previousImageID = 'banner-image-'+previousImage;
	
	//Current image number ID
	var currentImage = previousImage;
	
	currentImage++;
	
	//Current image html ID
	var currentImageID = 'banner-image-'+currentImage;
	
	//If the next image exists
	if($('#'+previousImageID).length == 1)
	{
		//Set the next image button to enabled
		$('#control-right').addClass('control-right-enabled').removeClass('control-right');
		
		//Get the images caption
		var caption = $('#'+previousImageID).attr('caption');
	
		//Fade out the current image and fade in the new one
		$('#'+currentImageID).fadeOut('fast', function(){
			
			//Update the caption
			$('.caption span').html(previousImage);
			
			//Fade in the new image
			$('#'+previousImageID).fadeIn();
		
		});
	
	}
	
	//Next image number ID
	var anteriorImage = previousImage;
	
	//Incriment for correct number ID
	anteriorImage--;
	
	//Next html ID
	var anteriorImageID = 'banner-image-'+anteriorImage;
	
	//If there is another image
	if($('#'+anteriorImageID).length == 1)
	{
	
		//Set the number ID of the next image on the next attribute
		$('#control-left').attr('previous', anteriorImage);
		
	}
	else
	{
	
		//If there are no more images disable the button
		$('#control-left').addClass('control-left').removeClass('control-left-enabled');
		
	}
	
	//Set the proxima image the the image before
	var proximaImage = anteriorImage;
	
	//Incriment the proxima image
	proximaImage++;
	proximaImage++;
	
	
	//Set the next attribute to the proxima image variable
	$('#control-right').attr('next', proximaImage);

}

function showNextBanner()
{

	//Next image number ID
	var nextImage = $('#control-right').attr('next');
	
	//Next image html ID
	var nextImageID = 'banner-image-'+nextImage;
	
	//Current image number ID
	var currentImage = nextImage - 1;
	
	//Current image html ID
	var currentImageID = 'banner-image-'+currentImage;
	
	//If the next image exists
	if($('#'+nextImageID).length == 1)
	{
		//Set the previous image button to enabled
		$('#control-left').addClass('control-left-enabled').removeClass('control-left');
		
		//Get the images caption
		var caption = $('#'+nextImageID).attr('caption');
	
		//Fade out the current image and fade in the new one
		$('#'+currentImageID).fadeOut('fast', function(){
			
			//Update the caption
			$('.caption span').html(nextImage);
			
			//Fade in the new image
			$('#'+nextImageID).fadeIn();
		
		});
			
		//Set the attribute to the current image variable
		$('#control-left').attr('previous', currentImage);
	
	}
	
	//Next image number ID
	var proximoImage = nextImage;
	
	//Incriment for correct number ID
	proximoImage++;
	
	//Next html ID
	var proximoImageID = 'banner-image-'+proximoImage;
	
	//If there is another image
	if($('#'+proximoImageID).length == 1)
	{
	
		//Set the number ID of the next image on the next attribute
		$('#control-right').attr('next', proximoImage);
		
	}
	else
	{
	
		//If there are no more images disable the button
		$('#control-right').removeClass('control-right-enabled').addClass('control-right');
		
	}

}

function subscribeNewsletter()
{

	//Runs the subscription for the website
	
	//Set the email variable
	var email = $('#subscribeEmail').val();
	
	//Perform the request
	$.ajax({
		url: "/_php/ajax/functions.php?f=subscribeNewsletter()&email="+email, 
		success: function(result){
		
			//If result is no empty replace the content of the div
			if(result != '')
			{
			
				$('#newsletter-subscribe').html(result);
		
			}
			
		}
	});

}

function switchMap(type)
{	

	//Function used for switching the iframe on the contact page.
	
	//Set the iframe variables
	var googleMapURLUSA = '<iframe id="googlemapEmbedUSA" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=212864102953417612346.0004609b3d46ce314c110&amp;ll=37.761148,-122.418122&amp;spn=0.002969,0.00456&amp;z=17&amp;output=embed"></iframe>';
	var googleMapURLUK = '<iframe id="googlemapEmbed" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=212864102953417612346.0004585b8cafd7568a774&amp;ll=51.553257,-0.144805&amp;spn=48.555061,135.263672&amp;z=15&amp;output=embed"></iframe>';
	var googleMapURLUAE = '<iframe id="googlemapEmbedUSA" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=212864102953417612346.00045eb8b1cec07c1b3f5&amp;ie=UTF8&amp;ll=25.257272,55.330238&amp;spn=0,0&amp;vpsrc=6&amp;output=embed"></iframe>';
	var googleMapURLPT = '<iframe id="googlemapEmbedPT" showing="youtube" width="675" height="304" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;ll=39.037418,-9.369132&amp;spn=48.688845,135.263672&amp;msid=212864102953417612346.0004a4810b03a441aa7a1&amp;z=16&amp;output=embed"></iframe>';

	if(type == 'USA')
	{
			
		$('#embedCode').html(googleMapURLUSA);
		$('#googleMapSwitcher').attr('showing', 'googleMapUSA');
		$('#video-caption').html('Google map of the MintTwist American office and local area');
	
	}
	
	if(type == 'UK')
	{
			
		$('#embedCode').html(googleMapURLUK);
		$('#googleMapSwitcher').attr('showing', 'googleMapUK');
		$('#video-caption').html('Google map of the MintTwist London office and local area');
	
	}
	
	if(type == 'UAE')
	{
			
		$('#embedCode').html(googleMapURLUAE);
		$('#googleMapSwitcher').attr('showing', 'googleMapUAE');
		$('#video-caption').html('Google map of the MintTwist UAE office and local area');
	
	}
	
	if(type == 'PT')
	{
			
		$('#embedCode').html(googleMapURLPT);
		$('#googleMapSwitcher').attr('showing', 'googleMapPT');
		$('#video-caption').html('Google map of the MintTwist Portuguese office and local area');
	
	}
	

}

function switchCalendarMonth(month, year)
{

	$.ajax({
		url: "/_php/ajax/calendar.php?f=switchCalendarMonth()&month="+month+"&year="+year, 
		success: function(result){
			$('#calendarArchive').html(result);
		}
	});

}

