/* -------------------- iPHONE DETECTION -------------------- */

var iphone = navigator.userAgent.match(/(iPhone|iPod)/i);


/* ------------------------- COOKIE ------------------------- */
     
function createCookie(name,content,day) {
	var expireDate = new Date();
	expireDate.setTime(expireDate.getTime() + day*24*3600*1000);
	document.cookie = name + "=" + escape(content)
         + ";expires=" + expireDate.toGMTString();
}
     
function readCookie(name) {
	var deb,fin
	deb = document.cookie.indexOf(name + "=")
	if (deb >= 0) {
		deb += name.length + 1
		fin = document.cookie.indexOf(";",deb)
		if (fin < 0) fin = document.cookie.length
		return unescape(document.cookie.substring(deb,fin))
	}
	return ""
}
     
function deleteCookie(name) { createCookie(name,"",-1) }


/* ---------------------------------------------------------- */


// resize width 100%
function iphoneResize() {
 	document.all.content.style.width = "100%";
}


if(langueDetected=="FR")
	var alertMessage = "T\351l\351charger l'application iPhone SHOPPING de myprestigium.com ?"
else if(langueDetected=="IT")
	var alertMessage = "Scarica l'applicazione iPhone SHOPPING di myprestigium.com ?"
else
	var alertMessage = "Download SHOPPING the myprestigium.com application for iPhone ?"


if(iphone){
	if ( readCookie('mypApp') == '' ) {
		if (confirm( alertMessage )) {
			createCookie('mypApp', 'accepted', 60);
			window.location.href = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=312076104";
		} else {
			createCookie('mypApp', 'refused', 7);
		}
	}
}
