document.domain = "smtown.com";

function NewWindow(mypage,myname,w,h,scroll){ 
  
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
	  settings +='width='+w+',';
	  settings +='top='+wint+',';
	  settings +='left='+winl+',';
	  settings +='scrollbars='+scroll+',';
	  settings +='resizable=no';
	  settings +='directories=no';
	  settings +='titlebar=no';
	  settings +='toolbar=no';
	  settings +='location=no';
	  settings +='menubar=no';
					  
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function NumObj(obj){

	if (event.keyCode >= 48 && event.keyCode <= 57) {

		return true;

	} else {

		event.returnValue = false;

	}

}

function Check(keyword) 
{
	var st_num, key_len;
	st_num = keyword.indexOf(" ");	
	while (st_num != -1)
	{
		keyword = keyword.replace(" ", "");
		st_num  = keyword.indexOf(" ");
	}
	key_len=keyword.length;
	return key_len;
}

function emailCheck(Email){
var t = escape(Email);
if(t.match(/^(\w+)@(\w+)[.](\w+)$/ig) == null && t.match(/^(\w+)@(\w+)[.](\w+)[.](\w+)$/ig) == null && t.match(/^(\w+)[.](\w+)@(\w+)[.](\w+)$/ig) == null && t.match(/^(\w+)[.](\w+)@(\w+)[.](\w+)[.](\w+)$/ig) == null){
return false
}else{
return;
}
}


function getSelectValue(p1,p2) {
 for (i=0; i<p1.options.length; i++ ) { 
 if( p1.options[i].value == p2 ) 
 p1.options[i].selected = true;
 }
}

function JuminCheck(jumin_no1, jumin_no2)
{
	check = false;
	total = 0;
	temp = new Array(13);

	if (jumin_no1 == '000000' && jumin_no2 == '0101001')
		check = true;
		
	for(i=1; i<=6; i++)
		temp[i] = jumin_no1.charAt(i-1);
	for(i=7; i<=13; i++)
		temp[i] = jumin_no2.charAt(i-7);
	
	for(i=1; i<=12; i++){
		k = i + 1;
		if(k >= 10)
			k = k % 10 + 2;
		total = total + (temp[i] * k);
	}
	totalmod = total % 11;

	if (totalmod > 1 )
		chd = 11 - totalmod;
	else
		chd = 1 - totalmod;

	if( chd == temp[13]  && (temp[7]==1 || temp[7]==2))
		check = true;
	return check;
}


function SelectNation(targ,selObj)
{
 var f = document.frm1;
 if ( selObj.options[selObj.selectedIndex].value != "Others" || selObj.options[selObj.selectedIndex].value == "" )
 {
	 f.nation_text.readOnly  = true;
 }
 else
 {
	 f.nation_text.value = "";
	 f.nation_text.readOnly  = false; 
	 f.nation_text.focus();
 }

}



function CheckUp(){
 
 var f = document.frm1;

 if ( f.nation.options[f.nation.selectedIndex].value == "Others" || f.nation.options[f.nation.selectedIndex].value == "")
 { 
	 if( Check(f.nation_text.value) < 2 )
	 {
		 alert("±¹°¡¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		 if(f.nation.options[f.nation.selectedIndex].value == "Others")
			 f.nation_text.focus();

		 return;
	 }
 }

  /*
  if( f.nation.options[f.nation.selectedIndex].value == "Others" || f.nation_text.value.toLowerCase() == "japan")
 {
	 alert("ÀÏº»Àº ÆÒÅ¬·´ °¡ÀÔ ÇØ´ç Áö¿ª¿¡¼­ Á¦¿ÜµË´Ï´Ù.");
	 f.nation_text.value = "";
	 return
 }
 */

 if( Check(f.txtKorName.value) < 2 ) {
   alert("¼º¸í(ÇÑ±Û)À» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtKorName.focus();
   return;
 }
 
 if( Check(f.txtEngName.value) < 2 ) {
   alert("¼º¸í(¿µ¹®)À» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtEngName.focus();
   return;
 } 


 if( Check(f.txtSSN1.value) != 6 || Check(f.txtSSN2.value) != 7 ) {
   alert("ÁÖ¹Î¹øÈ£¸¦ ÀÔ·ÂÇÏ½Ã¿À");
   f.txtSSN1.focus();
   return;
 }  
 

 if(!JuminCheck(f.txtSSN1.value, f.txtSSN2.value)){
	alert("¿Ã¹Ù¸£Áö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.");
	f.txtSSN1.value = "";
	f.txtSSN2.value = "";
	f.txtSSN1.focus();
    return;
  }

	 
		 
 if(f.txtMarriage[0].checked == false && f.txtMarriage[1].checked == false )
 {
	alert("°áÈ¥À¯¹«¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä");
	return;   
 }

 if ( Check(f.vc_zipcode1.value) < 2)
 {
   alert("¿ìÆí¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
   return;
 }

  if ( Check(f.vc_memAdd1.value) < 2)
 {
   alert("ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
   f.vc_memAdd1.focus();
   return;
 }



	if((f.vc_memPhone1.value=="" || f.vc_memPhone2.value=="" || f.vc_memPhone3.value=="" ) && (f.vc_memCell1.value=="" || f.vc_memCell2.value=="" || f.vc_memCell3.value=="" )){
   		alert("ÀüÈ­¹øÈ£(À¯¼±)À» ÀÔ·ÂÇÏ½Ã¿À");
   		f.vc_memPhone1.focus();
		return ;
	}


	if(f.vc_memCell2.value != "" && f.vc_memCell1.value == ""){
   		alert("ÀüÈ­¹øÈ£(¹«¼±)À» ÀÔ·ÂÇÏ½Ã¿À");
   		f.vc_memCell1.focus();
		return ;
	}
	
 if( Check(f.txtEmail.value) < 2 ) {
   alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtEmail.focus();
   return;
 }

 if( emailCheck(f.txtEmail.value) == false ) {
   alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Àß ¸ø µÇ¾ú½À´Ï´Ù.");
   f.txtEmail.focus();
   return;
 }
 
 if( Check(f.txtJob.value) < 2 ) {
   alert("Á÷¾÷À» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtJob.focus();
   return;
 }  
 
 if( Check(f.txtHobby.value) < 2 ) {
   alert("Ãë¹Ì¸¦ ÀÔ·ÂÇÏ½Ã¿À");
   f.txtHobby.focus();
   return;
 }  
 
 if( Check(f.txtBankDate.value) < 2 ) {
   alert("ÀÔ±ÝÀÏÀ» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtBankDate.focus();
   return;
 }   
 
 if( Check(f.txtBank.value) < 2 ) {
   alert("ÀÔ±ÝÀºÇàÀ» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtBank.focus();
   return;
 }     
 
 if( Check(f.txtBankTime.value) < 2 ) {
   alert("ÀÔ±Ý½Ã°£À» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtBankTime.focus();
   return;
 }    
  

 else  
	 
 {
   f.action = "fanclub_join_proc.asp";
   f.submit();

 }
 
}


function CheckUpResult(){
 
 var f = document.frm1;

	 
 if(f.txtMarriage[0].checked == false && f.txtMarriage[1].checked == false )
 {
	alert("°áÈ¥À¯¹«¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä");
	return;   
 }

 if ( Check(f.vc_zipcode1.value) < 2)
 {
   alert("¿ìÆí¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
   return;
 }

  if ( Check(f.vc_memAdd1.value) < 2)
 {
   alert("ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
   f.vc_memAdd1.focus();
   return;
 }



	if((f.vc_memPhone1.value=="" || f.vc_memPhone2.value=="" || f.vc_memPhone3.value=="" ) && (f.vc_memCell1.value=="" || f.vc_memCell2.value=="" || f.vc_memCell3.value=="" )){
   		alert("ÀüÈ­¹øÈ£(À¯¼±)À» ÀÔ·ÂÇÏ½Ã¿À");
   		f.vc_memPhone1.focus();
		return ;
	}


	if(f.vc_memCell2.value != "" && f.vc_memCell1.value == ""){
   		alert("ÀüÈ­¹øÈ£(¹«¼±)À» ÀÔ·ÂÇÏ½Ã¿À");
   		f.vc_memCell1.focus();
		return ;
	}
	
 if( Check(f.txtEmail.value) < 2 ) {
   alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ½Ã¿À");
   f.txtEmail.focus();
   return;
 }

 if( emailCheck(f.txtEmail.value) == false ) {
   alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Àß ¸ø µÇ¾ú½À´Ï´Ù.");
   f.txtEmail.focus();
   return;
 }
 


 else  
	 
 {
   f.action = "fanclub_join_result_proc.asp";
   f.submit();

 }
 
}



function CheckUpF(){
 
 var f = document.frm1;

 if ( f.nation.options[f.nation.selectedIndex].value == "Others" || f.nation.options[f.nation.selectedIndex].value == "")
 { 
	 if( Check(f.nation_text.value) < 2 )
	 {
		 alert("Please specify your country.");
		 if(f.nation.options[f.nation.selectedIndex].value == "Others")
			 f.nation_text.focus();
		 return;
	 }

 }

 /*
 if( f.nation.options[f.nation.selectedIndex].value == "Others" || f.nation_text.value.toLowerCase() == "japan")
 {
	 alert("Residents in Japan are not albe to join [S.M. ARTIST Official Global Fanclub].");
	 f.nation_text.value = "";
	 return
 }
  */
 
 if( Check(f.txtEngName.value) < 2 ) {
   alert("Please specify your name.");
   f.txtEngName.focus();
   return;
 } 


 if( Check(f.txtSN.value) < 2  ) {
   alert("Please specify your social security number.");
   f.txtSN.focus();
   return;
 }  
 

 if( f.BirthMonth.value == "" ) {
   alert("D O B date of birth.");
   f.BirthMonth.focus();
   return;
 } 

 if( f.BirthDay.value == "" ) {
   alert("D O B date of birth.");
   f.BirthDay.focus();
   return;
 } 


  if( f.BirthYear.value == "" ) {
   alert("D O B date of birth.");
   f.BirthYear.focus();
   return;
 } 

  if( f.txtAge.value == "" ) {
   alert("Please specify your age.");
   f.txtAge.focus();
   return;
 } 

 if(f.txtSex[0].checked == false && f.txtSex[1].checked == false )
 {
	alert("male/female");
	return;   
 }

 if(f.txtMarriage[0].checked == false && f.txtMarriage[1].checked == false )
 {
	alert("Choose your status.");
	return;   
 }

 if ( Check(f.vc_zipcode.value) < 2)
 {
   alert("Please specify your zipcode.");
   f.vc_zipcode.focus();
   return;
 }

  if ( Check(f.vc_memAdd1.value) < 2)
 {
   alert("Please specify your address");
   f.vc_memAdd1.focus();
   return;
 }
 		 

if( f.vc_memPhone.value=="" && f.vc_memCell.value=="" ){
   		alert("Please specify your phone number.");
   		f.vc_memPhone.focus();
		return ;
}

	
if( Check(f.txtEmail.value) < 2 ) {
   alert("Please specify your email address.");
   f.txtEmail.focus();
   return;
 }

 if( emailCheck(f.txtEmail.value) == false ) {
   alert("Incorrect e-mail address.");
   f.txtEmail.focus();
   return;
 }
 
 if( Check(f.txtJob.value) < 2 ) {
   alert("Please specify your job.");
   f.txtJob.focus();
   return;
 }  
 
 if( Check(f.txtHobby.value) < 2 ) {
   alert("Please specify your occupation.");
   f.txtHobby.focus();
   return;
 }  
 
 if( Check(f.txtBankDate.value) < 2 ) {
   alert("Please specify date of deposit.");
   f.txtBankDate.focus();
   return;
 }   
 
 if( Check(f.txtBank.value) < 2 ) {
   alert("Please specity bank of deposit.");
   f.txtBank.focus();
   return;
 }     
 
 if( Check(f.txtBankTime.value) < 2 ) {
   alert("Please specity time of deposit.");
   f.txtBankTime.focus();
   return;
 }    
  

 else  
	 
 {
   f.action = "fanclub_join_proc_eng.asp";
   f.submit();

 }
 
}


function CheckUpF_Result(){
 
 var f = document.frm1;


 if(f.txtMarriage[0].checked == false && f.txtMarriage[1].checked == false )
 {
	alert("Choose your status.");
	return;   
 }

 if ( Check(f.vc_zipcode.value) < 2)
 {
   alert("Please specify your zipcode.");
   f.vc_zipcode.focus();
   return;
 }

  if ( Check(f.vc_memAdd1.value) < 2)
 {
   alert("Please specify your address");
   f.vc_memAdd1.focus();
   return;
 }
 		 

if( f.vc_memPhone.value=="" && f.vc_memCell.value=="" ){
   		alert("Please specify your phone number.");
   		f.vc_memPhone.focus();
		return ;
}

	
if( Check(f.txtEmail.value) < 2 ) {
   alert("Please specify your email address.");
   f.txtEmail.focus();
   return;
 }

 if( emailCheck(f.txtEmail.value) == false ) {
   alert("Incorrect e-mail address.");
   f.txtEmail.focus();
   return;
 } 

 else  
	 
 {
   f.action = "fanclub_join_result_eng.asp";
   f.submit();

 }
 
}


function KeyUpCheckSSN()
{

 var f = document.frm1;
 var age, sex;
 if(!JuminCheck(f.txtSSN1.value, f.txtSSN2.value)){
	alert("¿Ã¹Ù¸£Áö ¾ÊÀº ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
	f.txtSSN1.value = "";
	f.txtSSN2.value = "";
	f.txtSSN1.focus();
    return;
  }
  else
  {
    sex = f.txtSSN2.value.substring(0,1);
    age = 107 - parseInt(f.txtSSN1.value.substring(0,2), 10);
    f.txtAge.value = age;
    
    if( sex == "1" || sex == "3")
      f.txtSex[0].checked = true;
    else
      f.txtSex[1].checked = true;
    
    
     
  }
}

function goMenu(GetValue)
{
   var NN;

   switch (GetValue)
   {
	 //¸ÞÀÎ   
     case "1" :
     location.href = "http://fanclub.smtown.com";
	 break;
	 //È¸¿ø¾à°ü
     case "2" :
     location.href = "http://www.smtown.com/event/Fanclub/fanclub_agreement.aspx";
//	 alert("Coming Soon!");
	 break;
	 //È¸¿øÆ¯Àü
     case "3" :
     location.href = "http://www.smtown.com/event/Fanclub/fanclub_benefits.aspx";
	// alert("Coming Soon!");
	 break;
	 //È¸ºñ¿ÍÈ°µ¿±â°£
     case "4" :
     location.href = "http://www.smtown.com/event/Fanclub/fanclub_subscription.aspx"; //fanclub.smtown.com
	// alert("Coming Soon!");
	 break;
	 //È¸¿ø°¡ÀÔÀýÂ÷
     case "5" :
     location.href = "http://www.smtown.com/event/Fanclub/fanclub_howtojoin.aspx";
	// alert("Coming Soon!");
	 break;
	 //FAQ
     case "6" :
     NN = NewWindow('template/fanclub_faq.htm','faq',400,400,1);
	 break;
	 //È¸¿ø°¡ÀÔÈ®ÀÎ
     case "7" :
     NN = NewWindow('fanclub_result_pop.htm','result',400,400,0);
	 break;
	 //Q&A
     case "8" :
     location.href = "http://www.smtown.com/help/helpList.aspx";
	 break;
	 //È¸¿ø°¡ÀÔ
     case "9" :
     location.href = "http://fanclub.smtown.com/index_page.asp";
	 break;
	 //ºñ¹ÐÀÏ±â
     case "10" :
    // location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx";
	 location.href = "http://www.smtown.com/event/Fanclub/fanclub_agreement.aspx";
	// alert("Coming Soon!");
	 break;
	 //´º½º°Ô½ÃÆÇ
     case "11" :
     location.href = "http://www.smtown.com/event/fanclub/FanclubNewsList.aspx";
	 break;
	 case "12" :
     location.href = "http://www.smtown.com";
	 break;
	 
	 default :
	 location.href = "http://fanclub.smtown.com/";
	 break;
   
   }
}


	/**********************************************************************************
	 Flash ÆÄÀÏ Ãß°¡ ½ºÅ©¸³Æ® 
    ***********************************************************************************/
	function loadFlash(filename,width,height,oMenu,oWmode)
	{	
		
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width +'" height="'+ height +'">'); 
		document.write('<param name="movie" value="'+ filename +'"><param name="quality" value="high">');

		if(oMenu)
			document.write('<param name="menu" value="false">');
		if(oWmode)
		{
			document.write('<PARAM NAME=wmode VALUE=transparent>'); 
			document.write('<embed src="'+ filename +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed></object>');
		}
	}


	function mpOpen(conID)
	{
		window.open("http://player.smtown.com/Player/mediaPlay.asp?id=" + conID + "","prgMP","width=350, height=390");
		return ;
	}

	function moveToUrl(boardId)   
    {
        var strBoardId = boardId;
        
        // µ¿¹æ½Å±â
        if(strBoardId == 'BA00911')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00911";                       
        }
        // ½´ÆÛÁÖ´Ï¾î
        if(strBoardId == 'BA00913')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00913";
        }
        // º¸¾Æ
        if(strBoardId == 'BA00914')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00914";
        }
        // Àå¸®ÀÎ
        if(strBoardId == 'BA00915')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00915";
        }
        // Æ®·¢½º
        if(strBoardId == 'BA00916')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00916";
        }
        // The Grace
        if(strBoardId == 'BA00917')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00917";
        }
        // °­Å¸
        if(strBoardId == 'BA00918')
        {
            location.href = "http://www.smtown.com/event/Fanclub/fanclub_specialmessage.aspx?BoardId=BA00918";
        }        
    }