var isfullscreen = false;
var isWin = (navigator.userAgent.indexOf('Win') != -1);
var isWinXP = (navigator.userAgent.indexOf('Windows NT 5.1') != -1);
var isIE = (navigator.userAgent.indexOf('MSIE') != -1);
var isNS = (navigator.userAgent.indexOf('Mozilla') != -1) && (navigator.userAgent.indexOf('Firefox') == -1);
var isFirefox = (navigator.userAgent.indexOf('Firefox') != -1);
var isMAC = (navigator.platform.indexOf('Mac') != -1);
var version = parseInt(navigator.appVersion);
var previousXPosition = 0;
var previousYPosition = 0;
var previousWidth = 0;
var previousHeight = 0;

function openScreenEvent() {
	url="http://fashion.chanel.com/omotesando";
	newwindow=true;
	reload=false;
	titlebar=true;
	reload = (typeof reload=="undefined") ? true : reload;
	if(isIE) {
		previousXPosition = top.window.screenLeft;
		previousYPosition = top.window.screenTop;
		previousWidth = document.body.clientWidth;
		previousHeight = document.body.clientHeight;
	} else if(self.outerWidth) {
		previousXPosition = self.screenX;
		previousYPosition = self.screenY;
		previousWidth = self.outerWidth;
		previousHeight = self.outerHeight;
	} else {
		previousXPosition = top.window.screenLeft;
		previousYPosition = top.window.screenTop;
		previousWidth = document.body.clientWidth;
		previousHeight = document.body.clientHeight;
	}
	if(isWin && isIE) {
		top.window.resizeTo(screen.width/2,screen.height/2);
		top.window.moveTo(0,0);
		var wleftdiff = top.window.screenLeft;
		var wrightdiff = (screen.width/2) - top.window.document.body.clientWidth - wleftdiff;
		var htopdiff = top.window.screenTop;
		var hbottomdiff = (screen.height/2) - top.window.document.body.clientHeight - htopdiff;
		var newXPosition = -wleftdiff;
		var newYPosition = -htopdiff;
		var newWidth = screen.width+wleftdiff+wrightdiff;
		var newHeight = screen.height+htopdiff+hbottomdiff;
		if((newWidth>screen.width) && (newHeight>screen.height)) {
			previousXPosition -= wleftdiff;
			previousYPosition -= htopdiff;
			previousWidth += wleftdiff+wrightdiff;
			previousHeight += htopdiff+hbottomdiff;
		}
		top.window.resizeTo(previousWidth,previousHeight);
		top.window.moveTo(previousXPosition,previousYPosition);
		parameters = "x="+previousXPosition+"&y="+previousYPosition+"&width="+previousWidth+"&height="+previousHeight;
		if(isWinXP || newwindow) {
			url = (url.indexOf('?') != -1) ? url+"&"+parameters : url+"?"+parameters;

            if(!titlebar)
            {
                arg = 'fullscreen=yes'
            }
            else
            {
                deltaWidth = -8;
                deltaHeight = -30;
                
                newWidth = screen.width + deltaWidth;
                newHeight = screen.height + deltaHeight;

                arg = 'width='+newWidth+',height='+newHeight+',left=0,top=0,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0'                
            }

            
			window.open(url,'omofullscreen', arg);
            if(!newwindow)
            {
                top.window.opener = top;
                top.window.close();
            }
		} else {
			top.window.moveTo(newXPosition-2,newYPosition-2);
			top.window.resizeTo(newWidth,newHeight);
			if(reload) {
				top.location.href = (url.indexOf('?') != -1) ? url+"&"+parameters : url+"?"+parameters;
			}
		}
	} else {
		deltaWidth = (isNS) ? ((isMAC) ? -10 : -5) : ((isMAC) ? -5 : 0);
		deltaHeight = (isNS) ? ((isMAC) ? -50 : -50) : ((isMAC) ? -2 : -30);
		deltaLeft = (isNS) ? ((isMAC) ? -6 : -6) : ((isMAC) ? -5 : -5);
		deltaTop = (isNS) ? ((isMAC) ? -30 : -30) : ((isMAC) ? -10 : -30);
		newWidth = screen.width + deltaWidth;
		newHeight = screen.height + deltaHeight;
		parameters = "x="+previousXPosition+"&y="+previousYPosition+"&width="+previousWidth+"&height="+previousHeight;
		url = (url.indexOf('?') != -1) ? url+"&"+parameters : url+"?"+parameters;
		newwin = window.open(url,'chanelfullscreen', 'width='+newWidth+',height='+newHeight+',left=0,top=0,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0');
		newwin.resizeTo(newWidth,newHeight);
		newwin.moveTo(0,0);
        if(!newwindow)
        {
            top.window.opener = top;
            top.window.close();
        }
	}

var url = "http://www.chanel.com/index.php?zone_lang=ASIJP";
location.href=url;
}
function redirectScreenEvent() {

var url = "http://www.chanel.com/index.php?zone_lang=ASIJP";
location.href=url;
}

