function acceptcondition()
{
	if( $('agree').checked==true )
	{
	  document.location.href='join-form.php';
	}
	else
	{
		alert('이용약관 및 개인정보 취급정책에 동의하셔야 가입하실 수 있습니다.');
	}
}

ImageSetting = function(){
	this.img = dom.$$($("scroll-content"), "IMG");
	this.popup_content = "";
	this.popup_content += "<html><head><title>큰 이미지 보기</title></head>"
	for(var i = 0; i < this.img.length; i++){
		var w = this.img[i].offsetWidth, h = this.img[i].offsetHeight;
		this.img[i].ow = w;
		this.img[i].oh = h;
		if(w > 560){
			this.img[i].style.height = parseInt(h/100) * parseInt(560/w*100) + "px";
			this.img[i].style.width = 560 + "px";
		}
		this.img[i].style.visibility = "visible";
		this.img[i].call = this;
		Event.observe(this.img[i], "click", function(){ this.call.popup(this) });
	}
}
ImageSetting.prototype = {
	create : function(w, h, path) {
		var popup_content = this.popup_content, win;
			popup_content += "<body style=\"margin: 0;\"><a href=\"#close\" onclick=\"window.close();\"><img src=\""+path+"\" border=\"0\" width=\""+w+"\" height=\""+h+"\" alt=\"이미지를 클릭하면 창이 닫힙니다.\" />";
			popup_content += "</a></body></html>";
		win = window.open("","bigimage","width="+w+",height="+h);
		win.document.open();
		win.document.write(popup_content);
		win.document.close();
	},
	popup : function(emt) {
		this.create(emt.ow, emt.oh, emt.getAttribute("src"));
	}
}

  function checkid() 
  {
    var url = '/pages/sisley/checklogin.php';
    var params = 'login=' + $('login').value;
    var ajax = new Ajax.Updater(
    {
		  success: 'logincheck'
	  },
      url,
    {
		  method: 'get', parameters: params
	  });

  }
	
	
	function isValidEmail(str) 
  {
    var filter=/^([\w-]+(?:\.[\w-']+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    return (filter.test(str))
  }

	function checkemail() 
  {
	  var url = '/pages/sisley/checkemail.php';
    var params = 'email=' + $('email').value;
    var params = params+'&currentemail=' + $('currentemail').value;		
	  var params = params+'&login=' + $('login').value;
	 
	  if( isValidEmail($('email').value) )
	  { 
	    var ajax = new Ajax.Updater(
      {
		    success: 'emailadresscheck'
	    },
        url,
      {
		    method: 'get', parameters: params
	    });
	  }
  }
		
  function disable_marry_date()
  {
		$("marrydate_year").disabled=1;
		$("marrydate_month").disabled=1;
		$("marrydate_day").disabled=1;
	}

	function enable_marry_date()
	{
		$("marrydate_year").disabled=0;
		$("marrydate_month").disabled=0;
		$("marrydate_day").disabled=0;
	}

	function mandatory()
  {
    var msg="";
	if( $('loginvalid').value != "valid" ) msg = msg + " - 아이디\n";
    if( $('password').value == "" ) msg = msg + " - 패스워드\n";
    if( $('confirmpassword').value != $('password').value ) msg = msg + " - 패스워드 확인\n";
    if( $('name').value == "" ) msg = msg + " - 이름\n";
    if( document.formulaire.gender.checked ) msg = msg + " - 성별 구분\n";
	//if( $('gender').checked ) msg = msg + " - 성별 구분\n";
    if( $('zipcode').value == "" || $('adress1').value == "" ) msg = msg + " - 주소\n"; 	
    if( document.formulaire.phone1.value == "" || $('phone2').value == "" || $('phone3').value == "" ) msg = msg + " - 전화번호\n"; 
		if( $('email').value == "" || !isValidEmail($('email').value)  || $('emailvalid').value != "valid" ) msg = msg + " - 이메일 주소\n"; 
		
		if( msg=="" )
		{
			 document.formulaire.submit(); 	
		}
	  else
	  {
			alert('다음의 항목을 정확하게 입력해 주세요: \n'+msg);
	  }
  }
	
	function updateinfos()
  {
    var msg="";

    if( $('passwordupdate').value == "" ) msg = msg + " - 패스워드\n";
    if( $('confirmpasswordupdate').value != $('passwordupdate').value ) msg = msg + " - 패스워드 확인\n";
    if( $('email').value == "" || !isValidEmail($('email').value)  || $('emailvalid').value != "valid" ) msg = msg + " - 이메일 주소\n"; 

    if( $('zipcode').value == "" || $('adress1').value == "" ) msg = msg + " - 주소\n"; 	
    if( document.formulaire.phone1.value == "" || $('phone2').value == "" || $('phone3').value == "" ) msg = msg + " - 전화번호\n"; 

		
		if( msg=="" )
		{
			 document.formulaire.submit(); 	
		}
	  else
	  {
			alert('다음의 항목을 정확하게 입력해 주세요: \n'+msg);
	  }
  }

function submitreview()
  {
    var msg="";

    if( $('product').value == "" ) msg = msg + " - 제품선택\n";
    if( $('title').value == "" ) msg = msg + " - 제목\n";
    if( $('body').value == "" ) msg = msg + " - 내용\n";
		
		if( msg=="" )
		{
			 document.formreview.submit(); 	
		}
	  else
	  {
			alert('다음의 항목을 정확하게 입력해 주세요: \n'+msg);
	  }
  }

  function submitevent()
  {
    var msg="";

    if( $('product').value == "" ) msg = msg + " - 연락처\n";
	if( $('product').value == "" ) msg = msg + " - 블로그url\n";
    if( $('title').value == "" ) msg = msg + " - 제목\n";
    if( $('body').value == "" ) msg = msg + " - 내용\n";
		
		if( msg=="" )
		{
			 document.formreview.submit(); 	
		}
	  else
	  {
			alert('다음의 항목을 정확하게 입력해 주세요: \n'+msg);
	  }
  }
		
		
	function submitcontact()
  {
    var msg="";

    if( $('name').value == "" ) msg = msg + " - 제품선택\n";
    if( !isValidEmail($('email').value) ) msg = msg + " - 제목\n";
    if( document.formcontact.body.value == "" ) msg = msg + " - 내용\n";
		
		if( msg=="" )
		{
			 document.formcontact.submit(); 	
		}
	  else
	  {
			alert('다음의 항목을 정확하게 입력해 주세요: \n'+msg);
	  }
  }



	function submitblog() 
  {
	  
		if( $('blogurl').value=="" || $('blogurl').value=="http://" )
		{
			alert('Please, fill your blog adress');
		}
	  else
	  {
		
		var url = '/pages/salon/submit_blog.php';
    var params = 'blogurl=' + $('blogurl').value;
   
 
	   var ajax = new Ajax.Updater(
     {
		   success: 'thxforparticipate'
	   },
       url,
     {
		   method: 'post', parameters: params
	   });		 
	 
	  }
  }
	
	
	function submitblog_two() 
  {
	  
		if( $('blogurl').value=="" || $('blogurl').value=="http://" )
		{
			alert('Please, fill your blog adress');
		}
	  else
	  {
		
		var url = '/pages/salon/submit_blog2.php';
    var params = 'blogurl=' + $('blogurl').value;
   
 
	   var ajax = new Ajax.Updater(
     {
		   success: 'thxforparticipate'
	   },
       url,
     {
		   method: 'post', parameters: params
	   });		 
	 
	  }
  }
	
	
	function recover_password()
	{

			var url = '/pages/sisley/password_recover.php';
      var params = 'name=' + $('name').value + '&email='+ $('email').value;
   
 
	   var ajax = new Ajax.Updater(
     {
		   success: 'recover_result'
	   },
       url,
     {
		   method: 'post', parameters: params
	   });		 

	}



	function reset()
  {
		
$('login').reset()
$('password').reset()
$('confirmpassword').reset()
$('name').reset()
$('birthday_year').reset()
$('birthday_month').reset()
$('birthday_day').reset()
document.formulaire.birthtype.reset();
document.formulaire.gender.reset();
$('zipcode').reset()
$('adress1').reset()
$('adress2').reset()
document.formulaire.phone1.reset();
$('phone2').reset()
$('phone3').reset()
$('hp1').reset()
$('hp2').reset()
$('hp3').reset()
$('email1').reset()
$('email2').reset()
document.formulaire.marry.reset();
document.formulaire.emailcheck.reset();
document.formulaire.smscheck.reset();
document.formulaire.store.reset();
document.formulaire.skintype.reset();
document.formulaire.skinstatus.reset();

$('whatchance1').reset();
$('whatchance2').reset();
$('whatchance3').reset();
$('whatchance4').reset();
$('whatchance5').reset();
$('whatchance6').reset();
$('whatchance7').reset();
$('whatchance8').reset();
$('whatchance9').reset();
$('whatchance10').reset();

$('otherbrand1').reset();
$('otherbrand2').reset();
$('otherbrand3').reset();
$('otherbrand4').reset();
$('otherbrand5').reset();
$('otherbrand6').reset();
$('otherbrand7').reset();
$('otherbrand8').reset();
$('otherbrand9').reset();
$('otherbrand10').reset();
$('otherbrand11').reset();
$('otherbrand12').reset();
$('otherbrand13').reset();
$('otherbrand14').reset();
$('otherbrand15').reset();
$('otherbrand16').reset();
$('otherbrand17').reset();
$('otherbrand18').reset();
$('otherbrand19').reset();

$('magazine1').reset();
$('magazine2').reset();
$('magazine3').reset();
$('magazine4').reset();
$('magazine5').reset();
$('magazine6').reset();
$('magazine7').reset();
$('magazine8').reset();
$('magazine9').reset()
$('magazine10').reset()
$('magazine11').reset()
$('magazine12').reset()
$('magazine13').reset()
$('magazine14').reset()
$('magazine15').reset()
$('magazine16').reset()
$('magazine17').reset()
$('magazine18').reset()
$('magazine19').reset()
$('magazine20').reset()
$('magazine21').reset()
$('magazine22').reset()
}

function nouvelleFenetre(url,width,height) {
  propriete = "top=60,left=100,resizable=no, toolbar=no, scrollbars=no, menubar=no, location=no, statusbar=no"
  propriete += ",width=" + width + ",height=" + height;
  win = window.open(url,"fenetre", propriete)
}

var KoreaShopList = Class.create({
	initialize: function() {
		this.size = 4;
		this.list = $$("table tbody > tr");
		this.page_info = $("shop-korea-page-info");
		this.page_link = $("shop-korea-page-link");
		this.page_links = new Array();
		this.page_now = null;
		this.page_total = Math.ceil(this.list.length / this.size);

		this.initDOM();
	},

	initDOM: function() {
		this.list.each(function(e, i) {
			if(i%2 != 0) e.addClassName("bg");
			e.addClassName("hide");
			e.colIndex = i;
		});
		
		for(var i = 0, pageCode, linkDivision; i < this.page_total; i++) {
			pageCode = new Element("a");
			linkDivision = (i + 1 == this.page_total) ? "" : "/";
			pageCode.appendChild(document.createTextNode(" "+(i+1)+" "));
			this.page_link.insert(pageCode);
			this.page_link.insert(linkDivision);
			this.page_links.push(pageCode);
			this.handler = this.showPage.bind(this, i);
			pageCode.observe("click",  this.handler);
		}

		this.showPage(0);
	},
	
	showPage: function() {
		this.togglePage(arguments[0]);
		this.updatePageInfo(arguments[0]+1);
	},
	
	togglePage: function(showNumber) {
		if(showNumber == this.page_now) return;
		this.page_links[showNumber].addClassName("reffer");
		if(this.page_now != null)
		this.page_links[this.page_now].removeClassName("reffer");
		for(var i = 0; i < this.size; i++) {
			if(this.list[showNumber * this.size + i])
				this.list[showNumber * this.size + i].removeClassName("hide");
			if(this.page_now != null && this.list[this.page_now * this.size + i])
				this.list[this.page_now * this.size + i].addClassName("hide");
		}
		this.page_now = showNumber;
	},
	
	updatePageInfo: function(showNumber) {
		var newPageInfo = showNumber + "/" + this.page_total;
		this.page_info.update(newPageInfo);
	}

});

// Makeup Product Color
var ProductColor = Class.create({
	initialize: function() {
		this.list = $$("#product-color-img img");
		this.trace = $("product-color");

		this.setEvent();
	},

	setEvent: function() {
		for(var i = 0; i < this.list.length; i++) {
			this.handler = this.toggleColor.bindAsEventListener(this, this.list[i].readAttribute("alt"));
			this.list[i].observe("mouseover",  this.handler);
		};
	},

	toggleColor: function(e, color_name) {
		this.trace.update(color_name);
	}
});


function SearchByNeed_Go(url) {
	if(url == 0) {
		alert("필요한 스킨케어를 선택하세요.");
		return;
	}
	window.location.href="/pages/products/search-by-need.php?index="+url;
};

function SearchByNeed_Man_Go(url) {
	if(url == 0) {
		alert("필요한 스킨케어를 선택하세요.");
		return;
	}
	window.location.href="/pages/products/search-by-need-man.php?index="+url;
};

function MakeupStyle_Go(url) {
	if(url == 0) {
		alert("당신의 메이크업 스타일을 고르세요.");
		return;
	}
	window.location.href="/pages/products/choose-makeup.php?index="+url;
};
/*
function GoLanguage(url) {
	if(url == 3) return;
	if(url ==1){window.location.href="http://www.sisley-cosmetics.com/fr-fr/";}
	if(url ==2){window.location.href="http://www.sisley-cosmetics.com/gb-en/";}
	if(url ==4){window.location.href="http://www.sisley-cosmetics.com/jp-jp/";}
	if(url ==5){window.location.href="http://www.sisley.com.cn";}
	if(url ==6){window.location.href="http://www.sisley.com.au";}
	if(url ==7){window.location.href="http://www.sisley.cz";}
	if(url ==8){window.location.href="http://www.sisley-cosmetics.com/de-de/";}
	if(url ==9){window.location.href="http://www.sisley.com.hk";}
	if(url ==10){window.location.href="http://www.sisley-cosmetics.com/it-it/";}
	if(url ==11){window.location.href="http://www.sisley.com.my";}
	if(url ==12){window.location.href="http://www.sisley-cosmeticos.com.mx";}
	if(url ==13){window.location.href="http://www.sisley.pl";}
	if(url ==14){window.location.href="http://www.sisley-cosmetics.com/ru-ru/";}
	if(url ==15){window.location.href="http://www.sisley.com.sg";}
	if(url ==16){window.location.href="http://www.sisley.es";}
	if(url ==17){window.location.href="http://www.sisley.com.tw";}
	if(url ==18){window.location.href="http://www.sisley.co.th";}
	if(url ==20){window.location.href="http://www.sisley-cosmetics.com/nl-nl/";}

};
*/

function GoLanguage(url) {
	if(url == 9) return;
	
	
	if(url ==1){window.location.href="http://www.sisley.com.au";}
	if(url ==2){window.location.href="http://www.sisley.cz";}
	if(url ==3){window.location.href="http://www.sisley.com.cn";}
	if(url ==4){window.location.href="http://www.sisley-cosmetics.com/fr-fr/";}
	if(url ==5){window.location.href="http://www.sisley-cosmetics.com/de-de/";}
	if(url ==6){window.location.href="http://www.sisley.com.hk";}
	if(url ==7){window.location.href="http://www.sisley-cosmetics.com/it-it/";}
	if(url ==8){window.location.href="http://www.sisley-cosmetics.com/jp-jp/";}
	if(url ==10){window.location.href="http://www.sisley.com.my";}
	if(url ==11){window.location.href="http://www.sisley-cosmetics.com/nl-nl/";}
	
	if(url ==12){window.location.href="http://www.sisley.pl";}
	if(url ==13){window.location.href="http://www.sisley-cosmeticos.com.mx";}
	if(url ==14){window.location.href="http://www.sisley-cosmetics.com/ru-ru/";}
	if(url ==15){window.location.href="http://www.sisley.com.sg";}
	if(url ==16){window.location.href="http://www.sisley.es";}
	if(url ==17){window.location.href="http://www.sisley.com.tw";}
	if(url ==18){window.location.href="http://www.sisley.co.th";}
	if(url ==19){window.location.href="http://www.sisley-cosmetics.com/gb-en/";}
	if(url ==20){window.location.href="http://www.sisley-cosmectics.com/us-en";}
	if(url ==21){window.location.href="http://www.sisleyumformen.com/kr/index.html";}
	if(url ==22){window.location.href="http://www.sisleya-fermete.com/kr/index.html";}
	if(url ==23){window.location.href="http://www.supremya.com/ko/index.html";}
	if(url ==24){window.location.href="http://www.skinleya.com/kr/index.html";}
	if(url ==25){window.location.href="http://www.eau-ikar.com/fr_fr/";}
};


function PagePrint() {
	var check = confirm("사용하시는 브라우저 설정에서 배경색 및 이미지 인쇄 옵션을 활성화 하셔야\n정상적으로 출력 됩니다.\n\n 예) 인터넷 익스플로러일 경우: 도구 - 인터넷 옵션 - 고급 - 인쇄(배경색 및 이미지 인쇄)");
	if(check) {
		window.print();
	}
};

function SendMail() {
	alert("준비중 입니다.");
};

function GetAdvice() {
	var blind_wrap = $("blind-content-wrap");
	var blind_content = $("blind-content");
	var params = "";
	blind_wrap.style.display = "block";
	if(arguments.length > 0) params = "?index="+arguments[0]+"&sub_index="+arguments[1];
	blind_content.setAttribute("src", "/pages/products/makeup-tip.php"+params);
	with(blind_content.style) {
		left = parseInt((blind_wrap.getWidth() - 1020) / 2) + "px";
		margin = "107px auto 0";
		width = "922px";
		height = "459px";
	}
};

function SendMail() {
	var params = "";
	var blind_wrap = ""
	var blind_content = ""
	if(window.parent) {
		params = window.location.href;
		blind_wrap = window.parent.$("blind-content-wrap");
		blind_content = window.parent.$("blind-content");
	} else {
		blind_wrap = $("blind-content-wrap");
		blind_content = $("blind-content");
	}
	blind_wrap.style.display = "block";
	with(blind_content.style) {
		left = parseInt((blind_wrap.getWidth() - 700) / 2) + "px";
		margin = "100px auto 0";
		width = "553px";
		height = "395px";
	}
	blind_content.setAttribute("src", "/pages/sendmail.php?ParamURL="+params);
};

function CloseAdvice() {
	if(window.parent)
	window.parent.$("blind-content-wrap").style.display = "none";
};

function CloseMail() {
	if(window.parent)
	window.parent.$("blind-content-wrap").style.display = "none";
};

var OnlineShop = Class.create({
	initialize: function() {
		this.toggle_button = $$("#onlineshop a")[0];
		this.toggle_content = $$("#onlineshop img")[0];
		this.toggle_content.hide();

		this.initEvent();
	},

	initEvent: function() {
		this.handler = this.toggle.bind(this);
		this.toggle_button.observe("click",  this.handler);
		this.toggle_content.observe("click",  this.handler);
	},
	
	toggle: function() {
		this.toggle_content.toggle();
	}
});
Event.observe(document, "dom:loaded", function() { if($("page-foot")) new OnlineShop() });

// Company
var Company = Class.create({
	initialize: function(no1, no2) {
		this.emt_locate = $("company_locate");
		this.emt_title = $("company_title");
		this.emt_content = $("scroll-content");
		this.emt_visual = $("company-visual");
		this.tmp_nav = $$("#sub-navigation a");
		this.emt_nav = null;
		this.now1 = null;
		this.now2 = null;

		this.setEvent();

		this.toggleContent(null, no1, no2);
	},

	setEvent: function() {
		var tmp_count = 0, tmp = new Array();
		this.tmp_nav.each(function(e, i) {
			if(e.hasClassName("d2")) {
				if(i > 0) tmp_count++;
				tmp[tmp_count] = new Array();
				tmp[tmp_count].push(e);
			} else {
				tmp[tmp_count].push(e);
			}
			e.observe("focus", function() { this.blur() });
		})

		this.emt_nav = tmp;
		for(i = 0; i < this.emt_nav.length; i++) {
			for(j = 0; j < this.emt_nav[i].length; j++) {
				this.handler = this.toggleContent.bindAsEventListener(this, i, j);
				this.emt_nav[i][j].observe("click", this.handler);
			}
		}
	},

	toggleContent: function(e, no1, no2) {
		var tmp = (no2 > 0) ? no2 - 1 : no2;
		if(this.now1 != no1) {
			this.emt_visual.style.backgroundImage = "url('"+CompanyVisual[no1][tmp]+"')";
			this.emt_locate.update(CompanyLocate[no1]);
			this.emt_title.update(CompanyLocate[no1]);
		}
		if(this.now2 != no2 || this.now1 != no1) {
			this.emt_content.update(CompanyContent[no1][tmp]);
			Scroll.init(true);
		}
		if(this.now1 != null) {
			this.emt_nav[this.now1][0].removeClassName("reffer");
			this.emt_nav[this.now1][this.now2].removeClassName("reffer");
		}
		this.emt_nav[no1][0].addClassName("reffer");
		this.emt_nav[no1][no2].addClassName("reffer");
		this.now1 = no1;
		this.now2 = no2;
	}
})



function recupere_valeur(Forms,form_name)
{
	for (i=0;i<Forms.length;i++)
   {
   	if (GetValeurCookie(Forms_Array[i])!=null)
   	{
   		eval('document.'+form_name+'.'+Forms_Array[i]+'.value=GetValeurCookie("'+Forms_Array[i]+'")');
   	}
   	else
   	{
   		eval('document.'+form_name+'.'+Forms_Array[i]+'.value=""');
   	}
	}
}

function Fix_All_Cookies(Forms,form_name)
{
	for (i=0;i<Forms.length;i++)
   {
   	eval(Forms_Array[i]+'=document.'+form_name+'.'+Forms_Array[i]+'.value');
   	if (Forms_Array[i]==""){Forms_Array[i]="null";}
   	eval('FixeCookie ("'+Forms_Array[i]+'",'+Forms_Array[i]+',null,"/")');
	}
	FixeCookie ("Fin","",null,"/");
}
	
function DateExpiration (DateExp) 
{
	var aujourdhui = new Date(0);
	var aujourdhuidate = aujourdhui.getTime();
	if (aujourdhuidate > 0)
	
	DateExp.setTime (DateExp.getTime() - aujourdhuidate);
}

function FixeCookie (nom,valeur,expire,path,domaine,securise) 
{
	document.cookie = nom + "=" + escape (valeur) + ((expire) ? "; expires=" + expire.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domaine) ? "; domain=" + domaine : "") + ((securise) ? "; secure" : "");
}

function SupprCookie (nom,path,domaine) 
{
	if (GetValeurCookie(nom))
	{
		document.cookie = nom + "=" + ((path) ? "; path=" + path : "") + ((domaine) ? "; domain=" + domaine : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


function ValeurCookie (Pos) 
{
	var endstr = document.cookie.indexOf (";", Pos);
	if (endstr == -1)

	Endstr = document.cookie.length;

	return unescape(document.cookie.substring (Pos, endstr));

}

function GetValeurCookie (nom) 
{
	var cookielength = document.cookie.length;
	var arg = nom + "=";
	var arglength = arg.length;
	var i = 0;
	while (i < cookielength) 
	{
		var j = i + arglength;
		if (document.cookie.substring(i, j) == arg)
		
		return ValeurCookie (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 	
	}
	return null;
}

	function resign()
  {
		if( $(reasonselected).value=="" ) 
		{  
			alert( "please, select the reason of your resignation\n" );
		}
		else
		{
		  rep=confirm('회원탈퇴시 고객님의 개인정보는 완전히 삭제됩니다. 정말 탈퇴하시겠습니까?')
	     if(rep) 
	     {
		     document.resign.submit();
	     }
			 
		}
    

  }


