$(document).ready(function(){
	
/*//remove home option from nav on index page
if $('body#index') {

$('.nav-home').css({visibility: "hidden"});
$('.ddsmoothmenu').css({width: "533px"});	

}else{

}*/



	
//create shadows in IE
/*var option = {
  x:      0, 
  y:      0, 
  radius: 40,
  color:  "#ffffff"
}								  
 $('body.creative .nav-creative span, body.consulting .nav-consulting span').textShadow(option);
 */
//Navigation Menu
ddsmoothmenu.init({
	mainmenuid: "smoothmenu1", //menu DIV id
	orientation: 'h' //Horizontal or vertical menu: Set to "h" or "v"
});



//event Banner
$('.events-banner')
.cycle({
	fx: 'scrollDown',
	speed: 1000,
	timeout: 6000,
	height: '253px',
	width: '455px',
	cleartypeNoBg: true
	
	
    });
	
//Sub event Banner
$('.sub-events-banner')
.cycle({
	fx: 'scrollDown',
	speed: 1000,
	timeout: 6000,
	height: '130px',
	width: '650px',
	cleartypeNoBg: true
	
    });
	
 //banner slideshow
$('.banners')
.cycle({
	fx: 'scrollRight',
	easing: 'linear',
	speed: 1200,
	timeout: 10000,
	startingSlide: 0,
	after:  onAfter,
	before: onBefore,
	   fit: 0,
        slideResize: 0
    });

//MATT 8/1/2012

    $(window).resize(function(){
		
	
       var w = $(window).width() ;
	   var ers = w + 'px';
	
	   if ( $("#slideholder").css('width') != ers) {
	   		
			$("#slideholder").css('width',ers);
			
	   
	   }
		
    });



//slideshow navigation
$('#home').click(function() { 
	//set color of text back to standard color
	$('#buttonContainer li').css({color: "#2c2c2c"});
	//remove any selected classes so that it defaults to original background 
	$('#creative').removeClass('creative-selected');
	$('#technology').removeClass('technology-selected');
	$('#consulting').removeClass('consulting-selected');
	//put the banner to the correct slide
    $('.banners').cycle(0); 
	//add the class of selected to have the correct bg image
	$('#home').addClass('home-selected');
	//set the home li to have the specific color
	$('#home').css({color: "#0000000"});

	
    return false; 
});

$('#creative').click(function() { 
	//set color of text back to standard color
	$('#buttonContainer li').css({color: "#2c2c2c"});
	//remove any selected classes so that it defaults to original background 
	$('#home').removeClass('home-selected');
	$('#technology').removeClass('technology-selected');
	$('#consulting').removeClass('consulting-selected');
	//put the banner to the correct slide	
    $('.banners').cycle(1);
	//add the class of selected to have the correct bg image
	$('#creative').addClass('creative-selected');
	//set the li to have the specific color 
	$('#creative').css({color: "#0000000"});

    return false; 
});
$('#consulting').click(function() { 
  //set color of text back to standard color
	$('#buttonContainer li').css({color: "#2c2c2c"});
	//remove any selected classes so that it defaults to original background 
	$('#home').removeClass('home-selected');
	$('#technology').removeClass('technology-selected');
	$('#creative').removeClass('creative-selected');
	//put the banner to the correct slide	
    $('.banners').cycle(2);
	//add the class of selected to have the correct bg image
	$('#consulting').addClass('consulting-selected');
	//set the li to have the specific color 
	$('#consulting').css({color: "#000000"});
  
    return false; 
});
$('#technology').click(function() { 
    //set color of text back to standard color
	$('#buttonContainer li').css({color: "#2c2c2c"});
	//remove any selected classes so that it defaults to original background 
	$('#home').removeClass('home-selected');
	$('#creative').removeClass('creative-selected');
	$('#consulting').removeClass('consulting-selected');
	//put the banner to the correct slide	
    $('.banners').cycle(3);
	//add the class of selected to have the correct bg image
	$('#technology').addClass('technology-selected');
	//set the li to have the specific color 
	$('#technology').css({color: "#000000"});
	
    return false; 
});

 
//function to get the current slide and tell it to do something on that slide
function onAfter(curr,next,opts) {

		if(opts.currSlide ==0){//if current slide is 0 which is the home slide 
		 //set color of text back to standard color
		  $('#buttonContainer li').css({color: "#2c2c2c"});
		  //remove any selected classes so that it defaults to original background 
		  $('#creative').removeClass('creative-selected');
		  $('#technology').removeClass('technology-selected');
		  $('#consulting').removeClass('consulting-selected');
		  //add the class of selected to have the correct bg image
		  $('#home').addClass('home-selected');
		  //set the home li to have the specific color
		  $('#home').css({color: "#000000"});
		
			
		}else 

		if	(opts.currSlide == 1){ //if the current slide is 1 which is the creative slide
				var creatglow = $('body#index .nav-creative .menuGlow').addClass("glow");
				$('body#index .nav-creative .hide').css({visibility: "visible"});
				if ($.browser.msie){
	
	$('.menuGlow').removeClass("glow");
	$('.hide').css({display: "none"}); 
	$('body.creative .nav-creative .hide, body.consulting .nav-consulting .hide').css({visibility: "hidden"});
}
		
	
		  //for the navigation of the slides
		  //set color of text back to standard color
		  $('#buttonContainer li').css({color: "#2c2c2c"});
		  //remove any selected classes so that it defaults to original background 
		  $('#home').removeClass('home-selected');
		  $('#technology').removeClass('technology-selected');
		  $('#consulting').removeClass('consulting-selected');
		  //put the banner to the correct slide	
		  $('.banners').cycle(1);
		  //add the class of selected to have the correct bg image
		  $('#creative').addClass('creative-selected');
		  //set the li to have the specific color 
		  $('#creative').css({color: "#000000"});
				
		}else
		
		if	(opts.currSlide == 2){ //if the current slide is 2 which is the consultancy slide
			var consultglow = $('body#index .nav-consulting .menuGlow').addClass("glow");
			$('body#index .nav-consulting .hide').css({visibility: "visible"});
			if ($.browser.msie){
	
	$('.menuGlow').removeClass("glow");
	$('.hide').css({display: "none"}); 
	$('body.creative .nav-creative .hide, body.consulting .nav-consulting .hide').css({visibility: "hidden"});
}
		
			//for the navigation of the slides
			//set color of text back to standard color
			$('#buttonContainer li').css({color: "#2c2c2c"});
			//remove any selected classes so that it defaults to original background 
			$('#home').removeClass('home-selected');
			$('#technology').removeClass('technology-selected');
			$('#creative').removeClass('creative-selected');
			//add the class of selected to have the correct bg image
			$('#consulting').addClass('consulting-selected');
			//set the li to have the specific color 
			$('#consulting').css({color: "#000000"});
			
		}else
		
		if (opts.currSlide == 3){// if the current slide is 3 which is the technology slide
			var technoglow = $('body#index .nav-technology .menuGlow').addClass("glow");
				$('body#index .nav-technology .hide').css({visibility: "visible"});
				if ($.browser.msie){
	
	$('.menuGlow').removeClass("glow");
	$('.hide').css({display: "none"}); 
	$('body.creative .nav-creative .hide, body.consulting .nav-consulting .hide').css({visibility: "hidden"});
}
	
			//for the navigation of the slides
			//set color of text back to standard color
			$('#buttonContainer li').css({color: "#2c2c2c"});
			//remove any selected classes so that it defaults to original background 
			$('#home').removeClass('home-selected');
			$('#creative').removeClass('creative-selected');
			$('#consulting').removeClass('consulting-selected');
			//add the class of selected to have the correct bg image
			$('#technology').addClass('technology-selected');
			//set the li to have the specific color 
			$('#technology').css({color: "#000000"});
				
		}
}
 

//need to remove any options that were set from the current slide
function onBefore(curr,next,opts) {

	$('.menuGlow').removeClass("glow");
	$('.hide').css({visibility: "hidden"}); 
	$('body#index .nav-consulting .menuGlow, body#index .nav-technology .menuGlow, body#index .nav-creative .menuGlow').fadeIn(100);

}



//makes the navigation glow but not in IE

var glow = $('body.creative .nav-creative .menuGlow, body.consulting .nav-consulting .menuGlow').addClass("glow"); 



//add the glow class which contains the css shadows

setInterval(function(){
   $('.glow').fadeToggle("slow"); // toggle the glowing class on and off
	 $('body.creative .nav-creative .hide, body.consulting .nav-consulting .hide').css({visibility: "visible"}); // because the glowing class contains the text and I couldnt toggle just the shadow, I created a hidden div containing the same word and am toggling this on and off at the same time. 
   
}, 1000);

if ($.browser.msie){
	
	$('.menuGlow').removeClass("glow");
	$('.hide').css({display: "none"}); 
	$('body.creative .nav-creative .hide, body.consulting .nav-consulting .hide').css({visibility: "hidden"});
}

//toggle maps

$('#swOffice').click(function(){
		$('#swOfficeMap').css({visibility: "visible"});
		$('#swOfficeMap').css({display: "block"});
		$('#headOfficeMap').css({display: "none"});
});

$('#headOffice').click(function(){
		$('#swOfficeMap').css({display: "none"});
		$('#headOfficeMap').css({visibility: "visible"});
		$('#headOfficeMap').css({display: "block"});
});

// validation form settings
$("#newsletter").validationEngine({
	inlineValidation: false
 });
 
//lightbox initialization
$(".meeting").fancybox({
	
  'titlePosition'		: 'inside',
  'transitionIn'		: 'none',
  'transitionOut'		: 'none',
  'hideOnOverlayClick'   : 'false'
 /* 'onClosed'          : function() {
					parent.location.reload(true); //reload the page so the data in the box does not remain
					}*/
});

$(".videoMessage").fancybox({
	
  'width'  : 587,
  'height'   : 484,
  'hideOnOverlayClick'   : 'false'
  /*'onClosed'          : function() {
					parent.location.reload(true); //reload the page so the data in the box does not remain
					}*/
});

$(".download").fancybox({
	
  'width'  : 620,
  'height'   : 520,
  'hideOnOverlayClick'   : 'false'
  
  /*'onClosed'          : function() {
					parent.location.reload(true); //reload the page so the data in the box does not remain
					}*/
});
	
/*//when the form button is clicked	
$("#meeting-form").submit(function(){
  
  //data from the form
  var data = $(this).serialize();
  //post the data using an ajax call
  $.ajax({
  type:"POST",
  url:"https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8",
  data:data,
  success: function(data) {
	  			$.fancybox(data); //update the lightbox
  			}
  });
  
return false;         
 });*/
	 
 //create the datepicker for the form. Because it conflicts with itself in the lightbox, it needs to re-assign its ID

$("#00ND0000003oFSU").live('focus', function(){ 
                 $(this).attr("id","00ND0000003oFSUNEWID");                 
                 $(this).datepicker({dateFormat: 'dd-mm-yy'});
	
});

//hides the subtitle div when the video is played 

	  $("#mainVideo").click(function () {
		
        $("#subtitle").hide("slow");
    });
   
 //detect if the user is on an apple, if they are, open the div so that there is an alternative menu
 
<!-- Checks to see if the user is using an apple device such as an iPhone or an iPad -->
<!--
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)))
{
	
$(".nav-technology").click(function (){
	$("#appleAboutMenu").slideUp("fast");
	$("#appleAboutMenu").css({visibility:"hidden"},{display:"none"});
	$(".ddsmoothmenu ul li ul").css({visibility:"hidden"});
	$(".logo").css({display:"none"});
	$(".appleNavLogo").css({display:"block"});
		$("#appleMenu").css({visibility:"visible"},{display:"block"});
		$("#appleMenu").slideDown(3000);
		$("body#index .strapline").css({display:"none"});
});// end of technology click function

$(".nav-about").click(function (){
	$("#appleMenu").slideUp("fast");
	$("#appleMenu").css({visibility:"hidden"},{display:"none"});
	$(".ddsmoothmenu ul li ul").css({visibility:"hidden"});
	$(".logo").css({display:"none"});
	$(".appleNavLogo").css({display:"block"});
		$("#appleAboutMenu").css({visibility:"visible"},{display:"block"});
		$("#appleAboutMenu").slideDown(3000);
		$("body#index .strapline").css({display:"none"});
});// end of about click function

		
	}//end of if iphone ipad
	
}); // end of doc ready

//hides the subtitle on the video
function hideSub(){
	
	
    $("#subtitle").hide("slow");
}

function videoPlaying() {
		$('.banners').cycle('pause');
		
}

function videoPaused()  {
		$('.banners').cycle('resume');
}

function swapVideo(flashurl, url) {
	 	/*alert(flashurl+" | "+url); */
	
		if (swfobject.getObjectById('FlashID') != null) // If we have a Flash player, let's tell it to play a new video
		{
			<!--alert('semlina');-->
			swfobject.getObjectById('FlashID').playVideo(flashurl);
		}
		else // If there is no Flash player, assume we are using an HTML5 player instead.
		{
			var videoplayer= document.getElementById('vid');
			videoplayer.autoplay="autoplay";
			videoplayer.src=url;
			videoplayer.load();
			
		//videoplayer.poster="ADEP_Big_thumb.jpg";
		}
		//thisMovie('FlashID').playVideo(flashurl); 
}


	function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }
	 
	 
	 
