// iPhone overlay behaviour

var iPhonePromo = {
	isIPhone: function() {
		var agent=navigator.userAgent.toLowerCase();
		var isIPhone = ((agent.indexOf('iphone')!=-1)&&(agent.indexOf('applewebkit')!=-1));
		return isIPhone;
	},
	isNewVisitor: function() {
		var seenBefore = readCookie(this.cookieName);
		return !seenBefore;
	},
	showOverlay: function() {
		iBox.show(this.overlayContent,null,{
			width: this.overlayWidth,
			height: this.overlayHeight
		});
		document.body.className += ' iphone_promo';
		createCookie(this.cookieName,true,28);
		// stopResize = true;
	},
	setGlobalOptions: function() {
		iBox.fade_in_speed = iBox.fade_out_speed = this.overlayAnimSpeed;
		iBox.padding = this.overlayPadding;
	},
	init: function() {
		// checks
		this.cookieName = 'iPhoneDownload201006Seen';
		if (!this.isIPhone() || !this.isNewVisitor() || !canUseCookies()) return;
		// variables
		this.overlayWidth = 710;
		this.overlayHeight = 270;
		this.overlayAnimSpeed = 0;
		this.overlayPadding = 100;
		// this.labelText = 'Your email address';
		window.fixAfterLoad = true; // stop repositioning
		window.repositionCount = 0; // after initial load
		// elements
		this.overlayContent = document.getElementById('iPhonePromoContent');
		// initialisation
		this.setGlobalOptions();
		this.showOverlay();
	}
};

if (window.addEventListener) {
	window.addEventListener('load',function(){iPhonePromo.init()},false);
};