var ns = (document.layers) ? 1:0;
var ns6 = (document.sidebar) ? 1:0;
var agt=navigator.userAgent.toLowerCase();
var is_ie=(agt.indexOf("msie")!=-1);
var is_net=(agt.indexOf("mozilla/5")!=-1);
var is_mac = agt.indexOf("mac")>-1;

if(is_ie || is_net) {
	var ie=true;
}   

if (ns) {
	widthCheck = window.innerWidth
	heightCheck = window.innerHeight
	window.onResize = resizeFix
}
function openwin(name,myname,mywidth,myheight,mytool,mydir,mystatus,myscroll,myresize,mymenu) 
{
	mytop=Math.floor((screen.height/2) - (myheight/2));
	myleft=Math.floor((screen.width/2) - (mywidth/2));
	debute =window.open(name,myname,"toolbar="+mytool+",width="+mywidth+",height="+myheight+",directories="+mydir+",status="+mystatus+",scrollbars="+myscroll+",top="+mytop+",left="+myleft+",resizable="+myresize+",menubar="+mymenu)
}


function  Showpopup(page) 
{
	switch (page)
	{
		case 'register':
		{
			openwin('http://www.chanel.com/register/en-us/register.php','USRegistration',800,380,0,0,0,0,0,0);
			break;
		}
		case 'brregister':
                {
            	openwin('http://www.chanel.com/register/pt-br/register.php','BRRegistration',800,380,0,0,0,0,0,0);
            		break;
        	}
		case 'vtour':
		{
			openwin('http://esite.chanel.com/57th/tour.html','vtour',929,615,0,0,0,0,0,0);
			break;
		}
		case 'legal':
		{
			openwin(strLegalURL,'legal',600,700,0,0,0,1,0,0);
			break;
		}
		case 'JPlegal':
		{
			openwin(strJPLegalURL,'legal',600,700,0,0,0,1,0,0);
			break;
		}
		case 'wynn':
		{
			openwin('http://www.chanel.com/wynn.html','wynn',580,301,0,0,0,0,0,0);
			break;
		}
		default:
		{
			break;
		}
	}
}



function opnPop(mypage)
{
	if (is_ie && ! is_mac)
        {
		if (typeof win == "undefined")
			window.open(mypage,'','fullscreen=1');
        }
	else
        {
		var win=window.open(mypage,'ahs','width='+screen.width+',height='+screen.height+',top=0,left=0');
        }
}

function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
                document.location.href = document.location.href
}

function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = getObjNN4(document,name);
		this.style = this.obj;
	}
}	

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var thereturn;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	thereturn = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) thereturn = tmp;
	}
	return thereturn;
}

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 openFullscreen(url,newwindow,reload, titlebar) {
	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,'chanelfullscreen', 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();
        }
	}
}

function openFullbridalscreen(url,newwindow,reload, titlebar) {
	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,'chanelbridalfullscreen', 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,'chanelbridalfullscreen', '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();
        }
	}
}

function ShwLegalInfo(lang)
{
 	
	switch (lang)
	{
		case 'fr': 
		{ 
			strLegaltext='MENTIONS LÃ‰GALES';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURFR&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','fr','ch_cat','FR Home Page');
			break; 
		}
		case 'ru':
        	{
            		strLegaltext='&#01070;&#01056;&#01048;&#01044;&#01048;&#01063;&#01045;&#01057;&#01050;&#01040;&#01071; &#01048;&#01053;&#01060;&#01054;&#01056;&#01052;&#01040;&#01062;&#01048;&#01071;';
            		strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURRU&src=ext';
            		FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','ru','ch_cat','RU Home Page');
            		break;
        	}
		case 'pt-br':
        	{
            	strLegaltext='AVISO LEGAL';
            	strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURBR&src=ext';
            	FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','pt-br','ch_cat','BR Home Page');
            		break;
        	}

		case 'de': 
		{
			strLegaltext='RECHTLICHE HINWEISE/ IMPRESSUM';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURDE&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','de','ch_cat','DE Home Page');
			break; 
		}
		case 'it': 
		{
			strLegaltext='INFORMAZIONI LEGALI';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURIT&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','it','ch_cat','IT Home Page');
			break;
		}
		case 'es': 
		{
			strLegaltext='ADVERTENCIAS LEGALES';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EURES&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','es','ch_cat','ES Home Page');
			break; 
		}
		case 'es-lx': 
		{
			strLegaltext='ADVERTENCIAS LEGALES';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=LATES&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','es','ch_cat','LATES Home Page');
			break; 
		}
		case 'en-gb': 
		{
			strLegaltext='LEGAL INFO';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EUREN&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','eur','ch_lang','en-gb','ch_cat','EN-GB Home Page');
			break; 
		}
		case 'en-us': 
		{
			strLegaltext='LEGAL STATEMENT';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=USAEN&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','nor','ch_lang','en-us','ch_cat','EN-US Home Page');
			break; 
		}
		case 'en-ca': 
		{
			strLegaltext='LEGAL INFO';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=EN-CA&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','nor','ch_lang','en-ca','ch_cat','EN-CA Home Page');
			break; 
		}
		case 'fr-ca': 
		{
			strLegaltext='MENTIONS LÃ‰GALES';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=FR-CA&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','nor','ch_lang','fr-ca','ch_cat','FR-CA Home Page');
			break; 
		}
		case 'en-as': 
		{
			strLegaltext='LEGAL INFO';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=ASIEN&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','asi','ch_lang','en-as','ch_cat','EN-AS Home Page');
			break; 
		}
		case 'zh-cn':
		{
			strLegaltext='&#27861;&#24459;&#22768;&#26126;';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=ASICN&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','asi','ch_lang','zh-cn','ch_cat','ZH-CN Home Page');
			break; 
		} 
		case 'kr': 
		{
			strLegaltext='ê·œì •';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=ASIKR&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','asi','ch_lang','kr','ch_cat','KR Home Page');
			break; 
		}
		case 'jp': 
		{
			strLegaltext='&#27861;&#30340;&#35201;&#20214;&#12395;&#20418;&#12431;&#12427;&#24773;&#22577;';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=ASIJP&src=ext';
			strJPLegaltext='&#12362;&#23458;&#27096;&#24773;&#22577;&#12398;&#21462;&#25201;&#12356;&#12395;&#12388;&#12356;&#12390;';
			strJPLegalURL='http://chanel.jp/privacy/index.html';
			FlashTrack('ch_div','homepages','ch_loc','asi','ch_lang','jp','ch_cat','JP Home Page');
			break; 
		}
		case 'zh-tw': 
		{
			//strLegaltext='ä½¿ç”¨æ¢?æ¬¾';
			strLegaltext='&#20351;&#29992;&#26781;&#27454;';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=ASITW&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','asi','ch_lang','zh-tw','ch_cat','ZH-TW Home Page');
			break; 
		} 
		default:
		{
			strLegaltext='LEGAL INFO';
			strLegalURL='http://www.chanel.com/info/legal/html/mentions_legales.php?zone_lang=USAEN&src=ext';
			FlashTrack('ch_div','homepages','ch_loc','nor','ch_lang','en-us','ch_cat','EN-US Home Page');
			break; 
		}
	}
	
	lyrLegalInfo = new getObj('spnLegal');
	lyrLegalInfo.obj.innerHTML = strLegaltext;
	lyrLegalInfo.obj.visibility='visible';
	
	if(lang=='jp'){
	lyrLegalInfo = new getObj('spnJPLegal');
	lyrLegalInfo.obj.innerHTML = strJPLegaltext;
	lyrLegalInfo.obj.visibility='visible';
	}
}


function shwURL()
{
	window.open (strLegalURL);
}


function ResetLegalInfo()
{
	lyrLegalInfo = new getObj('spnLegal');
	lyrLegalInfo.obj.innerHTML = '';
	lyrLegalInfo.obj.visibility='hidden';
     
        lyrLegalInfo = new getObj('spnJPLegal');
	lyrLegalInfo.obj.innerHTML = '';
	lyrLegalInfo.obj.visibility='hidden';

}




