 
$(document).ready(function(){
	$("#iOS-bg").css("opacity",0);
	$("#iOS-bg").css("display","block");
	$("#iOS-label").css("display","block");
	$("#iOS-text").css("display","block");
	
	if(isIE6 == true){$("#iOS-label").supersleight({shim: "assets/x.gif"});};
	
	var timerID;
	var backTimerID;
	var timerActive = 0;
	
	var parentWidth = $("#iOS-label-holder").width();
	
	var textWidth = $("#iOS-text").width() +60;
	var allowMove = 1;
	
		
	var rightPos = parentWidth -36 ;
	var leftPos = parentWidth - textWidth;
	
	$("#iOS-text").css({"left": rightPos, width:textWidth+"px"});
	
	
	function startTimer(){
    	
    	if(timerActive == 0){
    		clearTimeout(timerID);
    		timerID = setTimeout(function() { pulseArrow(); }, 1000);
    		timerActive = 1;
    	};
    };
    
    function pulseArrow(){
    	timerActive = 0;
    
    	/*$("#iOS-text").stop().animate({left:"-=3px", top:"+=3px" ,  useTranslate3d:true}, 200, "easeInOutCubic", function(){
    		$("#iOS-text").stop().animate({left:"+=3px", top:"-=3px" ,  useTranslate3d:true}, 200, "easeInOutCubic", function(){
    			$("#iOS-text").stop().animate({left:"-=3px", top:"+=3px" ,  useTranslate3d:true}, 200, "easeInOutCubic", function(){
					$("#iOS-text").stop().animate({left:"+=3px", top:"-=3px" ,  useTranslate3d:true}, 200, "easeInOutCubic", function(){
						startTimer();
					});
				});
    			
    		});
    		
    	});*/
    	
    	$("#iOS-text").css({"left":rightPos, "top":"0px"});
    	$("#iOS-text").animate({left:"-=5px" , top:"+=5px",  useTranslate3d:true}, 200, "easeInCubic", pulse1);
    	
    	
    	
    };

	function pulse1(){
			$(this).css("opacity:1");
			$(this).animate({left:"+=5px" , top:"-=5px",  useTranslate3d:true}, 200, "easeOutCubic", pulse2);
		
	}
	
	function pulse2(){
			$(this).css("opacity:0");
			$(this).animate({left:"-=5px" , top:"+=5px",  useTranslate3d:true}, 200, "easeInCubic", pulse3);
		
	}
    function pulse3(){
			$(this).css("opacity:1");
			$(this).animate({left:"+=5px" , top:"-=5px",  useTranslate3d:true}, 200, "easeOutCubic", startTimer);
		
	}


    $("#iOS-label").mouseenter(function() {
		if(allowMove == 1){
			clearTimeout(timerID);
			timerActive = 0;
		
		};
	});
	$("#iOS-label").mouseleave(function() {
		if(allowMove == 1){
			startTimer();
			timerActive = 1;
		};
	});
	
	$("#iOS-label").click(function() { 
  	//alert(textWidth)
  	  	
  	  		
  	  		if(allowMove == 1){
				
  	  			allowMove = 0;
  	  			clearTimeout(timerID);
  	  			timerActive = 0;
  	  			$("#iOS-text").css({"left":rightPos, "top":"0px"}).stop().animate({left:leftPos, useTranslate3d:true}, 300, "easeInOutCubic", function(){
  	  				//allowMove = 1;
  	  				backTimerID = setTimeout(function() { returnStrip(); }, 1000);
  	  			});   	  			 
  	  		}
  	   	  	  		
  	  		
	});
	
	function returnStrip(){
		$("#iOS-text").css("left", leftPos).stop().animate({left:rightPos, useTranslate3d:true}, 300, "easeInOutCubic", function(){
  	  			allowMove = 1;
  	  			clearTimeout(backTimerID);
  	  			startTimer();
  	  			timerActive = 1;
  	  	});   
	
	}
	
	startTimer();
		
});


    



