function
appStoreCookie ()
{
    var expires = new Date();
    expires.setTime(expires.getTime() + 90 * 1000 * 60 * 60 * 24);
    document.cookie = 'skip_fr_detect=flase' + ';expires=' + expires.toGMTString();
}

function
appStoreDetect ()
{
    if (document.cookie.indexOf('skip_fr_detect=false') == -1) {
	var agent = navigator.userAgent.toLowerCase();
	var type;
	var opera = (agent.indexOf('opera') != -1);
	var forumName = '';

	if (agent.indexOf('iphone') != -1) {
	    type = 'iPhone';
	} else if (agent.indexOf('ipod') != -1) {
	    type = 'iPod Touch';
	} else if (agent.indexOf('ipad') != -1) {
	    type = 'iPad';
	} else {
	    return;
	}
	
	var operaMsg = 'For a better mobile experience of Nem-Q, download the free iPhone app. Go to the AppStore?';
	var safariMsg = 'For a better mobile experience of Nem-Q, download the free iPhone app. Go to the AppStore?';

	if (forumName != '') {
	    operaMsg = 'For a better mobile experience of Nem-Q, download the free iPhone app. Go to the AppStore?';
	    safariMsg = 'For a better mobile experience of Nem-Q, download the free iPhone app. Go to the AppStore?';
	}

	if (opera) {
	    appStoreCookie();
	    alert(operaMsg);
	    return;
	}

	if (confirm(safariMsg)) {
	    window.location = 'http://itunes.apple.com/nl/app/nem-q/id342464811?mt=8';	
	} else {
	    appStoreCookie();
	}
    }
}

appStoreDetect();
