// Player
function Play()
{	
	parent.mplayer.WMPlay.Play();
}

function Stop()
{
	parent.mplayer.WMPlay.Stop();
}

function Stop2()
{
	opener.top.frames[0].WMPlay.Stop();
}


function stopBGM()
{
	top.frames[0].WMPlay.Stop();
}

/*-------------------------------------------------------------------------
       공백여부 체크
	  -------------------------------------------------------------------------*/
 function isEmpty( data ){
     for ( var i = 0 ; i < data.length ; i++ ){
        if ( data.substring( i, i+1 ) != " " )
            return false;
     }
     return true;
    }
  
	  

		/*-------------------------------------------------------------------------
		   쿠키 생성
		  -------------------------------------------------------------------------*/
		function setCookie( name, value, expiredays ) 
		{ 
			var todayDate = new Date(); 
				todayDate.setDate( todayDate.getDate() + expiredays ); 
				document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
		} 
		
		 /*-------------------------------------------------------------------------
       쿠키 가져오기
	  -------------------------------------------------------------------------*/
	function getCookie( name ){
		var nameOfCookie = name + "=";
		var x = 0;
		while ( x <= document.cookie.length )
		{
			var y = (x+nameOfCookie.length);
			if ( document.cookie.substring( x, y ) == nameOfCookie ) {
				if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
				return unescape( document.cookie.substring( y, endOfCookie ) );
			}
				
			x = document.cookie.indexOf( " ", x ) + 1;
				
			if ( x == 0 ) break;
		}
				return "";
	}
	


	// Main Page Set Language
	function initializeLanguage(language)
	{
		var strLanguage = language;

		var f = document.form1;	

		if(strLanguage == "")
		{
			setCookie('Lang', 'kor', 1300);	
		}
		if(strLanguage == 'kor')
		{
			//setCookie('Lang', 'kor', 1300);	
			location.href = "Index.asp?Language=kor";
		}				
		if(strLanguage == 'chn')
		{
			//setCookie('Lang', 'chn', 1300);	
			location.href = "Index.asp?Language=chn";
		}
		if(strLanguage == 'jpn')
		{
			//setCookie('Lang', 'jpn', 1300);	
			location.href = "Index.asp?Language=jpn";
		}
		if(strLanguage == 'eng')
		{
			//setCookie('Lang', 'eng', 1300);	
			location.href = "Index.asp?Language=eng";
		}
		if(typeof document.form1 == "object")
		{
			f.submit();
		}
	}
	
	// SM Audition
	function getLanguage(language)
	{
		var lang = language;

		if(lang == 'kor')
		{
			setCookie('Lang', 'kor', 1300);	
			location.href = "SmAudition.asp";
		}
		if(lang == 'chn')
		{
			setCookie('Lang', 'chn', 1300);	
			location.href = "SmAudition.asp";
		}
		if(lang == 'jpn')
		{
			setCookie('Lang', 'jpn', 1300);	
			location.href = "SmAudition.asp";
		}
		if(lang == 'eng')
		{
			setCookie('Lang', 'eng', 1300);	
			location.href = "SmAudition.asp";
		}
	}
	
	// Global Audition
	function getLanguage2(language, pageNumber)
	{
		var lang = language;

		if(lang == 'kor')
		{
			setCookie('Lang', 'kor', 1300);	
			location.href = "GlobalAudition" + pageNumber + ".asp";
		}
		if(lang == 'chn')
		{
			setCookie('Lang', 'chn', 1300);	
			location.href = "GlobalAudition" + pageNumber + ".asp";
		}
		if(lang == 'jpn')
		{
			setCookie('Lang', 'jpn', 1300);	
			location.href = "GlobalAudition" + pageNumber + ".asp";
		}
		if(lang == 'eng')
		{
			setCookie('Lang', 'eng', 1300);	
			location.href = "GlobalAudition" + pageNumber + ".asp";
		}
	}

	function chkCookie(contentId, pageNumber)
	{
		var strCookie = getCookie("Lang");
				
		// SM Audition
		if(strCookie == '' || strCookie.length > 0)
		{
			strCookie = 'kor';	
		}
		if(strCookie == 'kor' && contentId == 'sm')
		{
			getLanguage(strCookie, contentId, pageNumber);	
		}
		if(strCookie == 'chn' && contentId == 'sm')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
		if(strCookie == 'jpn' && contentId == 'sm')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
		if(strCookie == 'eng' && contentId == 'sm')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
		// Global Audition
		if(strCookie == 'kor' && contentId == 'global')
		{
			alert(strCookie + " | " + contentId + " | " + pageNumber);
			getLanguage(strCookie, contentId, pageNumber);	
		}
		if(strCookie == 'chn' && contentId == 'global')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
		if(strCookie == 'jpn' && contentId == 'global')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
		if(strCookie == 'eng' && contentId == 'global')
		{
			getLanguage(strCookie, contentId, pageNumber)	
		}
	}

	function setLanguage(language)
	{
		if(language == 'kor')
			setCookie('Lang', 'kor', 1300);		
			document.location.reload();							
		if(language == 'chn')
			setCookie('Lang', 'chn', 1300);		
			document.location.reload();	
		if(language == 'jpn')
			setCookie('Lang', 'jpn', 1300);		
			document.location.reload();	
		if(language == 'eng')
			setCookie('Lang', 'eng', 1300);		
			document.location.reload();	
	}
	
		
// Menu
function goMenu(menu)
{		
   	var p;
	
	switch(menu) 
	{
		// HOME 
		case "0" :
			Stop();
			location.href = "/";
	    break;
		// NEWS&NOTICE
		case "1" :			
			location.href = "http://211.233.45.57/ASP/Audition/NoticeList.asp";
	    break;
		// SM Audition
		case "2" :
			location.href = "http://211.233.45.57/ASP/Audition/SmAudition.asp";	
	    break;
		// Global Audition
		case "3" :
			location.href = "http://211.233.45.57/ASP/Audition/GlobalAudition00.asp";
	    break;
		// Contest
		case "4" :
			window.alert("Coming Soon!");
	    break;
		// FAQ
		case "5" :			
			location.href = "http://211.233.45.57/ASP/Audition/FAQList.asp";
	    break;
		// Contact us
		case "6" :
			location.href = "http://211.233.45.57/ASP/Audition/template/Contactus.htm";
	    break;		
		// Default
		default :
			location.href = "/";
		break;			
	}
}

// Menu
function menuGlobalAudition(menu)
{		
   	var p;
	
	switch(menu) 
	{
		// America & Canada 
		case "0" :
			location.href = "GlobalAudition01.asp";
	    break;
		// Thailand
		case "1" :			
			location.href = "GlobalAudition02.asp";
	    break;
		// Malaysia
		case "2" :
			location.href = "GlobalAudition03.asp";	
	    break;	
		// Video Clip(오디션 현장)
		case "3" :
			location.href = "GlobalAudition04.asp";	
	    break;	
		// Photo Clip
		case "4" :
			location.href = "GlobalAudition05.asp";	
	    break;	
		// Default
		default :
			location.href = "/";
		break;			
	}
}

// Lyrics
function openLyric(flag)
{
	var strFlag = flag;
			
	if(strFlag == '1')
	{	
		window.open('/template/album_Lyric/lyric_01.htm','lyric1','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '2')
	{			
		window.open('/template/album_Lyric/lyric_02.htm','lyric2','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '3')
	{			
		window.open('/template/album_Lyric/lyric_03.htm','lyric3','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '4')
	{		
		window.open('/template/album_Lyric/lyric_04.htm','lyric4','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '5')
	{			
		window.open('/template/album_Lyric/lyric_05.htm','lyric5','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '6')
	{		
		window.open('/template/album_Lyric/lyric_06.htm','lyric6','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '7')
	{			
		window.open('/template/album_Lyric/lyric_07.htm','lyric7','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '8')
	{			
		window.open('/template/album_Lyric/lyric_08.htm','lyric8','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '9')
	{			
		window.open('/template/album_Lyric/lyric_09.htm','lyric9','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '10')
	{			
		window.open('/template/album_Lyric/lyric_10.htm','lyric10','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '11')
	{			
		window.open('/template/album_Lyric/lyric_11.htm','lyric11','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
	if(strFlag == '12')
	{			
		window.open('/template/album_Lyric/lyric_12.htm','lyric11','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=468,height=600,left=0,top=0,resizable=no'); 
	}
}

	// Album Info
   function GoAlbumInfo(menu)
   {
     if( menu == "1")
	   document.frames("ifrm").location.href = "album_ifm_introduce.htm";
     if( menu == "2")
	   document.frames("ifrm").location.href = "album_ifm_review.htm";
     if( menu == "3")
	   document.frames("ifrm").location.href = "album_ifm_track.htm";	   	 
   }


	function moveToUrl(flag)
	{
		var _flag = flag;
		
		switch(_flag)
		{
			case "1" : 
				location.href = "/template/album_intro_3rdalbum.htm";
				break;
			case "2" : 
				location.href = "album_iframe/discography.htm";
				break;
			case "3" : 
				break;
			case "4" : 
				break;
			case "5" : 
				break;
			default :				
				break;			
		}	
	}

	function moveToNextGallery(galleryId)
	{
		strGalleryId = galleryId;

		if(strGalleryId == '0')
		{
			location.href = "/template/Gallery.htm";
		}
		if(strGalleryId == '1')
		{
			location.href = "/template/Gallery_01.htm";
		}
		if(strGalleryId == '2')
		{
			location.href = "/template/Gallery_02.htm";
		}
		if(strGalleryId == '3')
		{
			location.href = "/template/Gallery_03.htm";
		}
		if(strGalleryId == '4')
		{
			location.href = "/template/Gallery_04.htm";
		}
		if(strGalleryId == '5')
		{
			location.href = "/template/Gallery_05.htm";
		}
		if(strGalleryId == '6')
		{
			location.href = "/template/Gallery_06.htm";
		}		
	}


	function swapIframe(contentId)
	{
		var strContentId = contentId; 	
				
		// Null
		if( getCookie( 'Lang' ) == '' && strContentId == 'Introduce') 
		{
			document.all.ifrm.src = "album_iframe/Intro_3rdAlbum.htm";										
		}
		if( getCookie( 'Lang' ) == '' && strContentId == 'Review') 
		{
			document.all.ifrm.src = "album_iframe/Review_3rdAlbum.htm";												
		}
		if( getCookie( 'Lang' ) == '' && strContentId == 'List') 
		{
			document.all.ifrm.src = "album_iframe/Track_3rdAlbum.htm";												
		}
		
		// kor		
		if( getCookie( 'Lang' ) == 'kor' && strContentId == 'Introduce') 
		{
			document.all.ifrm.src = "album_iframe/Intro_3rdAlbum.htm";										
		}
		if( getCookie( 'Lang' ) == 'kor' && strContentId == 'Review') 
		{
			document.all.ifrm.src = "album_iframe/Review_3rdAlbum.htm";												
		}
		if( getCookie( 'Lang' ) == 'kor' && strContentId == 'List') 
		{
			document.all.ifrm.src = "album_iframe/Track_3rdAlbum.htm";												
		}
		
		// Chn		
		if( getCookie( 'Lang' ) == 'chn' && strContentId == 'Introduce') 
		{
			document.all.ifrm.src = "album_iframe/Intro_3rdAlbum_e.htm";										
		}
		if( getCookie( 'Lang' ) == 'chn' && strContentId == 'Review') 
		{
			document.all.ifrm.src = "album_iframe/Review_3rdAlbum_e.htm";												
		}
		if( getCookie( 'Lang' ) == 'chn' && strContentId == 'List') 
		{
			document.all.ifrm.src = "album_iframe/Track_3rdAlbum_e.htm";												
		}			

		// Jpn		
		if( getCookie( 'Lang' ) == 'jpn' && strContentId == 'Introduce') 
		{
			document.all.ifrm.src = "album_iframe/Intro_3rdAlbum_e.htm";										
		}
		if( getCookie( 'Lang' ) == 'jpn' && strContentId == 'Review') 
		{
			document.all.ifrm.src = "album_iframe/Review_3rdAlbum_e.htm";												
		}
		if( getCookie( 'Lang' ) == 'jpn' && strContentId == 'List') 
		{
			document.all.ifrm.src = "album_iframe/Track_3rdAlbum_e.htm";												
		}			

		// Eng
		if( getCookie( 'Lang' ) == 'eng' && strContentId == 'Introduce') 
		{
			document.all.ifrm.src = "album_iframe/Intro_3rdAlbum_e.htm";										
		}
		if( getCookie( 'Lang' ) == 'eng' && strContentId == 'Review') 
		{
			document.all.ifrm.src = "album_iframe/Review_3rdAlbum_e.htm";												
		}
		if( getCookie( 'Lang' ) == 'eng' && strContentId == 'List') 
		{
			document.all.ifrm.src = "album_iframe/Track_3rdAlbum_e.htm";												
		}							
	}
	
		function swapIframe2(contentId)
		{
			var strContentId = contentId;

			if(strContentId == 'release')
			{
				document.all.ifrm.src = "album_iframe/Intro_3rdAlbum.htm";	
			}
			if(strContentId == 'discography')
			{				
				location.href = "AlbumInfo_Disco.htm";
			}
		}

		function openUrl()
		{
			top.location.href = "http://ab.tvxq.com";	
		}

		
		function goJpop()
		{
		  //alert("coming soon!");
		  window.location.href="http://j-pop.smtown.com";
		}