var params = {
			  menu: "false",
			  allowfullscreen: "true",
			  allowscriptaccess: "always",
			  wmode: "window",
			  bgcolor: "#000000"
			};
			
var attributes = {
  id: "main",
  name: "main"
};		
    		
swfobject.embedSWF ( "main.swf", "flashEmbed", "100%", "100%", "10", "expressInstall.swf", null, params, attributes );
swfobject.addLoadEvent(loadEventHandler);

var iDevice = navigator.userAgent.match(/iPhone/i) != null || navigator.userAgent.match(/iPod/i) != null || navigator.userAgent.match(/iPad/i) != null;

if(iDevice){
	
	window.addEventListener("load", function() {
											 //alert("load event");
											 setTimeout(loaded, 100);
									}, false);
	
	window.onload = function initialLoad(){  
		loaded();  
	}  
}

if(document.images){
	var buttonUp = new Image(59, 91);
	buttonUp.src = "mobile/next_up.png";
	
	var buttonDown = new Image(59, 91);
	buttonDown.src = "mobile/next_down.png";	
}
		
function loadEventHandler() {
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "margin:0;padding:0;overflow:hidden;height:100%;");
}

function onImageTransitionDone() {
	showNextDown(false);
}

function setNextButton() {
	
	var isIE = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
	
	if(!isIE){
		var image = document["nextButtonImage"];
		image.src = buttonUp.src;		
		var anchor = document.getElementById("nextArea");
		
		
	
		if(iDevice){
			var holder = document.getElementById("nextButtonHolder");
			
			holder.addEventListener("touchstart", function(event){
														 event.preventDefault();
														 }
			);
			
			
			anchor.addEventListener("touchstart", function(event){
														event.preventDefault();
														showNextDown(true);
												  }
			);
			/*
			anchor.addEventListener("touchend", function(event){
														 event.preventDefault();
														 showNextDown(false);
												}
			);
			*/
	 
			
		} else {
			anchor.addEventListener("mousedown", function(){
				showNextDown(true);
			});
			/*
			anchor.addEventListener("mouseup", function(){
				showNextDown(false);
			});
			*/
		}
	}
}

function loaded() { 
    window.scrollTo(0, 1); // pan to the bottom, hides the location bar  
}  

function showNextDown(active) {
	if (document.images) {		
		var image = document["nextButtonImage"];
		image.src = active ? buttonDown.src : buttonUp.src;
	}
	if(active){
		StopSlideShow();
		AdvanceToNextImage();
		return false;
	}
}
