function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1) || 
		(navigator.platform.indexOf("iPad") != -1)
    );
}

$(document).ready(function() {
             
				$('a.vert').bind('click',function(event){
					
					event.preventDefault();					  
												  
                    var $anchor = $(this);
             
			 	 	var topvar = $($anchor.attr('href')).offset().top;

                    $('html, body').stop().animate({scrollTop: topvar}, 2000, function(){ 
					if (isiPhone()) { menu.follow(); if(topvar > 0) { $('#homelogo').fadeIn(); } else { $('#homelogo').fadeOut(); } } });
							
                });
				
				// Roundabout
				
				var interval;
				
				$('ul#serviceslist').roundabout({ shape: 'tearDrop', tilt: 0 }).hover(
						function() {
							clearInterval(interval);
						},
						function() {
							interval = startAutoPlay();
						}
					);
				
				interval = startAutoPlay();
					
				function startAutoPlay() {
				return setInterval(function() {
					$('ul#serviceslist').roundabout_animateToNextChild();
				}, 3000);
				}	
				
				// Targets
				
				$(function () { // same as $(document).ready(function () { })
				  // assuming we have the open class set on the H2 when the HTML is delivered
				  $('LI.drawer H2:not(.open)').next().hide();
				
				  $('H2.drawer-handle').click(function () {
					// find the open drawer, remove the class, move to the UL following it and hide it
					$('H2.open').removeClass('open').next().slideToggle();
					
					// add the open class to this H2, move to the next element (the UL) and show it
					$(this).addClass('open').next().slideToggle();
				  });
				});
				
				// Masonry 
						  
				$('#container').masonry({
				  itemSelector: '.box',
				  columnWidth: 390,
				  isAnimated: !Modernizr.csstransitions
				});
				
				// Tweet
					
				$(".tweet").tweet({
					username: "thisisbenchmark",
					join_text: "auto",
					avatar_size: 48,
					count: 1,
					auto_join_text_default: "",
					auto_join_text_ed: "",
					auto_join_text_ing: "",
					auto_join_text_reply: "",
					auto_join_text_url: "",
					loading_text: "loading tweet..."
			  
			});
				
				if (isiPhone()) { 
				
				// var iScroller = new iScroll('wrapper', { hScrollbar: false, vScrollbar: true });
				
				$('#scrolled').hide();
				
				menu = new followAlong('header');
				
				}
			
});

function rotateto(child) { 

$('ul#serviceslist').roundabout_animateToChild(child); return false;

}

prev = ''; 

$('ul#serviceslist li').focus(function(e) {

var selected = $(this).attr('id'); if (prev == '') { prev = selected; } 

$('#det_' + prev).fadeOut('fast', function() { $('#det_' + selected).fadeIn('fast'); }); prev = selected;

});
