if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPod') != -1) {
	$(document).ready(function(){
		setTimeout(function(){window.scrollTo(0, 0);}, 100);
		$("#faq strong").click(function(e){$(this).siblings("p").slideToggle(300);});
		$("#stepper").before('<div class="title">'+$("#lite h2").text()+"</div>");
		$("#iphone").prepend('<div id="step-messages">'+$("#step1").text()+'</div>');
		$("#m1 span").text("What people say");
		$("#m7 span").text("Download NestVest Lite Now");
		$("#lite h2").text("NestVest Lite");
		$("#pro h2").text("NestVest Pro");
		$("h2").wrapInner("<span></span>");
		$("#back, .borders").hide();

		$("#m2").parent().html('<li><a href="#products" rel="#lite" class="golite"><span>NestVest Lite</span></a></li>'+
		'<li class="download" id="dnl"><a href="'+$("#lite .its a").attr("href")+'">Download NestVest Lite Now</a></li>'+
		'<li><a href="#products" rel="#pro" class="gopro"><span>NestVest Pro</span></a></li>'+
		'<li class="download" id="dnp"><a href="'+$("#pro .its a").attr("href")+'">Download NestVest Pro Now</a></li>');
		if($("#pro .its a").attr("href")=="") $("#dnp").html('');
		var inmenu = true;

		$("a[href^=#]").click(function(){
			setTimeout(function(){window.scrollTo(0, 0);}, 100);
			if (inmenu)	{
				$("#back, .borders").show();
				$(".content, #pro, #lite").hide().filter(this.hash).show();
				if ($(this).hasClass("golite")) $("#products .big-title .golite").click();
				else if ($(this).hasClass("gopro")) $("#products .big-title .gopro").click();

				//$("#menu, #applogo, .borders").animate({left:"-=100%"}, 300, "swing");
				$("#menu, #applogo").css({left:"-100%"});
				$(".borders").css({left:"0%"});
				inmenu=false;
			} else {
				$(".content, #pro, #lite").hide().filter(this.hash).show();
				if ($(this).hasClass("golite")) $("#products .big-title .golite").click();
				else if ($(this).hasClass("gopro")) $("#products .big-title .gopro").click();
				inmenu=false;
			}
			return false;
		});

		$("th.lite").click(function(){
			$(".content, #pro, #lite").hide().filter("#products, #step-messages").show();
			$("#products .big-title .golite").click();
		});

		$("th.pro").click(function(){
			$(".content, #pro, #lite, #step-messages").hide().filter("#products").show();
			$("#products .big-title .gopro").click();
		});

		$("#back").click(function(){

			setTimeout(function(){window.scrollTo(0, 0);}, 100);

			$("#menu, #applogo").show();
			/*$("#menu, #applogo, .borders").animate({left:"+=100%"}, 300, "swing", function(){
				$("#back, .borders").hide();
			});*/
			$("#menu, #applogo").css({left:"0%"});
			$(".borders").css({left:"100%"});
			$("#back, .borders").hide();
			inmenu=true;
			return false;
		});

		$("#products .gopro").click(function(){
			$("#lite, #lite-step-images, #step-messages").hide();
			$("#pro, #pro-images").show();
			$("#products .big-title .gopro").hide();
			$("#products .big-title .golite").show();
		});
		
		$("#products .golite").click(function(){
			$("#pro, #pro-images").hide();
			$("#lite, #lite-step-images, #step-messages").show();
			$("#products .big-title .golite").hide();
			$("#products .big-title .gopro").show();
		});

		$("#step-items > div").click(function(e){
			if (!$(e.target).hasClass("step-active")){;

				$("#step-items > div.step-active").removeClass('step-active');

				var step = $(e.target).attr("rel");
				$(e.target).addClass('step-active');
				$("#step-messages").text($(step).text());
				$("#lite-step-images > div").hide().filter(step+"img").show();

			}
		});
	});
} else {
	$(document).ready(function(){
		$("#faq strong").click(function(e){
			$(this).siblings("p").slideToggle(300);
		});
		
		$("#step-items > div").mouseover(function(e){
			if (!$(e.target).hasClass("step-active")){
				$("#bar").stop(true,false);
				$("#lite-step-images > div").stop(true,true);
				$("#lite-step-images > div").fadeOut(200);
				$("#stepper > p").stop(true,true);
				$("#step-items > div.step-active").removeClass('step-active');
				$("#stepper > p:visible").hide();
				var offset = $("#step-items > div:first").position().left;
				var slide = $(e.target).position().left - offset;
				var step = $(e.target).attr("rel");
				var stepImg = $(e.target).attr("rel");
				
				$("#bar").animate({marginLeft:slide},200, 'swing', function(){
					$(e.target).addClass('step-active');
					$(stepImg+"img").fadeIn(200);
					$(step).fadeIn(200);
				});
			}
		});
		
		$("tr").mouseover(function(e){
			$(this).children("td").addClass('hover');
		});
		$("tr").mouseout(function(e){
			$(this).children("td").removeClass('hover');
		});
		
		$(".golite, a.golite").click(function(event){
			$("#version-choice:visible").fadeOut(300);
			$("#iphone:hidden").fadeIn();
			$("#pro-images").fadeOut(200);
			
			$("#products > .big-title > .subtitle").hide();
			$("#products > .big-title > .golite").hide();
			$("#thepro").hide(); $("#thelite").show();
			$("#pro").hide();
			$("#products > .big-title").animate({marginLeft:"0px"}, 800, 'swing', function(){
				$("#lite").fadeIn(300, function(){
					$("#products > .big-title > .gopro").fadeIn(300);
				});
			});
			
			$("#iphone").animate({marginLeft: "540px"}, 500, 'swing', function(){
				$("#lite-step-images").show();
			});
			window.location.hash = "#lite";
			return false;
		});
		
		$(".gopro, a.gopro").click(function(event){
			$("#version-choice:visible").fadeOut(300);
			$("#iphone:hidden").fadeIn();
			$("#lite-step-images").fadeOut(200);
			
			$("#products > .big-title > .subtitle").hide();
			
			$("#products > .big-title > .gopro").hide();
			$("#thelite").hide(); $("#thepro").show();
			$("#lite").hide();
			$("#products > .big-title").animate({marginLeft:"300px"}, 800, 'swing', function(){
				$("#pro").fadeIn(300, function(){
					$("#products > .big-title > .golite").fadeIn(300);
				});
			});
			$("#iphone").animate({marginLeft: "54px"}, 500, 'swing', function(){
				$("#pro-images").show();
				
			});
			window.location.hash="#pro";
			return false;
		});
		
		$("a[href^=#]:not(.golite,.gopro)").click(function(){
			$(this).blur();
			$(".content:visible").hide();
			
			//Reset Products page
			if(this.hash == "#products") {
				$("#products > :animated").stop(false,false);
				$("#thepro, #thelite").hide();
				$("#pro, #lite").hide();
				$("#products > .big-title > .gopro, #products > .big-title > .golite").hide();
				$("#products > .big-title").animate({marginLeft:"220px"},500, 'swing');
				$("#iphone").hide();
				$("#products > .big-title > .subtitle").show();
				$("#version-choice").show();
			} 
			$("#menu > li > a.active").removeClass("active");
			$("#menu > li > a").filter("[href="+this.hash+"]").addClass("active");
			window.location.hash=this.hash;
			$(this.hash).show();
			return false;
		});
		
		/* IE png workaround, pre-render for shadows under text */
		$(document).pngFix();
		$(".content").show();
		
		
		
		$(".title").FontEffect({
			gradient: true,
			gradientColor:"#fff",
			gradientPosition:33,
			gradientLength:33,
			gradientSteps:20,
			
			shadow:true,
			shadowColor:"#000",
			shadowOffsetTop:3,
			shadowOffsetLeft:0,
			shadowOpacity:0.1,
			shadowBlur:1
		});

		$(".y-title").FontEffect({
			gradient: true,
			gradientColor:"#fcac23",
			gradientPosition:33,
			gradientLength:33,
			gradientSteps:20,
			
			shadow:true,
			shadowColor:"#000",
			shadowOffsetTop:3,
			shadowOffsetLeft:0,
			shadowOpacity:0.1,
			shadowBlur:1
		});
		
		$(".subtitle").FontEffect({
			shadow:true,
			shadowColor:"#000",
			shadowOffsetTop:2,
			shadowOffsetLeft:0,
			shadowOpacity:0.13,
			shadowBlur:1
		});
		$(".content").hide();
		
		$("#iphone-on-fire").css({marginLeft:"330px"}).animate({marginLeft: "530px"}, 700, 'swing');
		
		var loc = window.location.hash;
		var pl = window.location.hash;
		
		if (loc.length<1) loc = $("#menu > li > a:first").attr("href");
		else if (loc=='#pro' || loc=='#lite') loc="#products";
		
		$("#menu > li > a").filter("[href="+loc+"]").addClass("active").click();	
		
		if (pl=="#pro") $("#nv-pro > .gopro").click();
		else if (pl=="#lite") $("#nv-lite > .golite").click();

		$("#step1").show();
		$("#step1img").show();
		$('#testimonials').cycle('fade');
	});
}

function hideURLbar() {
	window.scrollTo(0, 1);
}