$(function() {
	//messagebar
	$('#messageflash').hide();
	$('#messageflash').slideDown('slow').delay(5000).slideUp('slow');

	//showhide recaptcha
	if (!($('#errormessage').children().size() > 0 )){
  		$("#recaptcha_area").hide();
  	}

  	$("form input").change(function(){
		$("#recaptcha_area:hidden").show("slow");
  	});

	$("ul.sf-menu").superfish();

	//homepage flash
	$('#homesplash').cycle({ 
	  	fx: 'fade',
	    speed:  2000, 
	    timeout: 5000, 
	    pager:  '#homesplashnav', 
	    pagerEvent: 'mouseover',
	    allowPagerClickBubble: true,

	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
			if (idx) {
				return '<li><a href="'+slide.title+'">' + slide.alt + '</a></li>'; 
			} else {
				return '<li></li>'; 
			}
	    } 
	});

	//product fancybox
	$(".gallery a").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true'
	});
	
	//news fancybox
	$("#newsright a").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true'
	});
	
	//page
	$("#pageimage a").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true'
	});
	
	$(".pageimage2").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true'
	});
	
	$(".casestudies a.caseimage").fancybox({
		'titlePosition': 'over',
		'autoScale': 'true'
	});
	
	//googlemaps
	if ($('#map').length>0){
		initialize();
	}
	
	//introduction ticker 
	$('.introduction').vTicker({
	   speed: 500,
	   pause: 1000,
	   showItems: 8,
	   animation: 'fade',
	   mousePause: false,
	   height: 0,
	   direction: 'up'
	});
	
	
	
	$(window).load(function() {
	    $("#mcs_container").mCustomScrollbar("vertical",310,"easeOutCirc",0,"auto","yes","yes",10);
	});

});



//google maps function
function initialize() {
    var middleeast = new google.maps.LatLng(31.052934,42.890625);
    var africa = new google.maps.LatLng(7.013668,17.578125);
    var europe = new google.maps.LatLng(53.330873,17.929688);
    var asia = new google.maps.LatLng(30.600094,130.957031);
    var americas = new google.maps.LatLng(-19.47695,-62.226562);

	var myOptions = {
    	zoom: 3,
    	center: middleeast,
    	mapTypeId: google.maps.MapTypeId.HYBRID
    };
    var map = new google.maps.Map(document.getElementById("map"), myOptions);

	
	function moveafrica() {  
		$('#map').hide();
		$('#map').fadeIn('slow');
		map.setCenter(africa); 
	 }
	
	function moveeurope() { 	
		$('#map').hide();
		$('#map').fadeIn('slow');
		map.setCenter(europe);	
	}
	
	function moveasia() { 
		$('#map').hide();
		$('#map').fadeIn('slow');
		map.setCenter(asia);	
	}
	
	function moveamericas() { 
		$('#map').hide();
		$('#map').fadeIn('slow');
		map.setCenter(americas);	
	}
	
	function movemiddleeast() { 
		$('#map').hide();
		$('#map').fadeIn('slow');
		map.setCenter(middleeast);	
	}
	
	$('#moveafrica').click(function() { moveafrica(); });
	$('#moveeurope').click(function() { moveeurope(); });
	$('#moveasia').click(function() { moveasia(); });
	$('#movemiddleeast').click(function() { movemiddleeast(); });
	$('#moveamericas').click(function() { moveamericas(); });
}
