/*-------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------*/
function wOpenPopUp(s_Url,sLink,sName,sWidth,sHeight)
{
	var bellurl;
	bellurl=s_Url+"?"+sLink ;
	
	var popup=window.open(bellurl,sName,'scrollbars=no, left=20px;,top=20px;resizable=no,width='+sWidth+',height='+sHeight+'');
	popup.focus();
}


/*-------------------------------------------------------------------------------------------------------
- Define : »õÃ¢¿­±â - ½ºÅ©·Ñ
- Para	 : 
- sample : 
--------------------------------------------------------------------------------------------------------*/
function wOpenPopUp_scroll(s_Url,sLink,sName,sWidth,sHeight)
{
	var bellurl;
	bellurl=s_Url+"?"+sLink ;
	
	var popup=window.open(bellurl,sName,'scrollbars=yes, left=20px;,top=20px;resizable=no,width='+sWidth+',height='+sHeight+'');
	popup.focus();
}

/*-------------------------------------------------------------------------------------------------------
- Define : xpÀÏ¶§ »çÀÌÁî¸¦ ´Ã·ÁÁØ´Ù
- Para	 : 
- sample : 
--------------------------------------------------------------------------------------------------------*/
function ChkXp2(){
/*
	var sNav = (navigator.appVersion);
	var nPos = sNav.indexOf("NT 5.1; SV1")

	if(nPos != -1){
		window.resizeBy(0,30);
	}

*/
	arrList = new Array();

	arrList[arrList.length]  = "Microsoft Internet Explorer";
	arrList[arrList.length]  = "MSIE 7.0";
	arrList[arrList.length]  = "NT 5.1; SV1";
	
	var Frame_Body  = document.body;	
	Frame_Body.width = Frame_Body.clientWidth+10;
	Frame_Body.height = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight) + 110;
	
	
        var browserStr = ""
        var versionStr = ""
        browserStr += navigator.appName 
        versionStr += navigator.appVersion + "\r"
 
	//explorer ÀÎÁö Ã¼Å©
        if(browserStr == arrList[0])        {          
        	//explorer 4.0 ÀÌ»ó ÀÎÁö Ã¼Å©
        	if(parseFloat(versionStr) >= 4)         	{
				
        		//ÇöÀç ¹öÁ¯ÀÌ 7.0 ÀÏ °æ¿ì¿¡
        		if(versionStr.indexOf(arrList[1]) > 0)   	{
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}	 
        		if(versionStr.indexOf(arrList[2]) > 0)   	{
					
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}					
        			
        	}
        	
        }
 
}
function ChkXp3(){
/*
	var sNav = (navigator.appVersion);
	var nPos = sNav.indexOf("NT 5.1; SV1")

	if(nPos != -1){
		window.resizeBy(0,30);
	}

*/
	arrList = new Array();

	arrList[arrList.length]  = "Microsoft Internet Explorer";
	arrList[arrList.length]  = "MSIE 7.0";
	arrList[arrList.length]  = "NT 5.1; SV1";
	
	var Frame_Body  = document.body;	
	Frame_Body.width = Frame_Body.clientWidth+0;
	Frame_Body.height = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight) + 70;
	
	
        var browserStr = ""
        var versionStr = ""
        browserStr += navigator.appName 
        versionStr += navigator.appVersion + "\r"
 
	//explorer ÀÎÁö Ã¼Å©
        if(browserStr == arrList[0])        {          
        	//explorer 4.0 ÀÌ»ó ÀÎÁö Ã¼Å©
        	if(parseFloat(versionStr) >= 4)         	{
				
        		//ÇöÀç ¹öÁ¯ÀÌ 7.0 ÀÏ °æ¿ì¿¡
        		if(versionStr.indexOf(arrList[1]) > 0)   	{
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}	 
        		if(versionStr.indexOf(arrList[2]) > 0)   	{
					
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}					
        			
        	}
        	
        }
 
}

function ChkXp4(){
/*
	var sNav = (navigator.appVersion);
	var nPos = sNav.indexOf("NT 5.1; SV1")

	if(nPos != -1){
		window.resizeBy(0,30);
	}

*/
	arrList = new Array();

	arrList[arrList.length]  = "Microsoft Internet Explorer";
	arrList[arrList.length]  = "MSIE 7.0";
	arrList[arrList.length]  = "NT 5.1; SV1";
	
	var Frame_Body  = document.body;	
	Frame_Body.width = Frame_Body.clientWidth+10;
	Frame_Body.height = Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight) + 50;
	
	
        var browserStr = ""
        var versionStr = ""
        browserStr += navigator.appName 
        versionStr += navigator.appVersion + "\r"
 
	//explorer ÀÎÁö Ã¼Å©
        if(browserStr == arrList[0])        {          
        	//explorer 4.0 ÀÌ»ó ÀÎÁö Ã¼Å©
        	if(parseFloat(versionStr) >= 4)         	{
				
        		//ÇöÀç ¹öÁ¯ÀÌ 7.0 ÀÏ °æ¿ì¿¡
        		if(versionStr.indexOf(arrList[1]) > 0)   	{
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}	 
        		if(versionStr.indexOf(arrList[2]) > 0)   	{
					
	        		window.resizeTo(Frame_Body.width, Frame_Body.height);
	        	}					
        			
        	}
        	
        }
 
}


/*-------------------------------------------------------------------------------------------------------
- Define : ÀÌ¹ÌÁö on off
- Para	 : 
- sample : 
--------------------------------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------------------------------------
- Define : ÀÌ¹ÌÁö on off
- Para	 : 
- sample : 
--------------------------------------------------------------------------------------------------------*/

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

/*################################# WINDOW FUNCTION ################################################### 
----- À©µµ¿ì ÄÁÆ®·Ñ¿¡ ´ëÇÑ °ø¿ëÇÔ¼ö
\###################################################################################################*/

/*-------------------------------------------------------------------------------------------------------
- Define :ÆË¾÷Ã¢À» ¿¬´Ù
- Para	 : url, name, width, height
--------------------------------------------------------------------------------------------------------*/
function GetOpenWin(sUrl, sName, nWidth, nHeight) {
	window.open(sUrl,sName,"status=no,toolbar=no,location=no,scrollbars=no,width="+nWidth+",height="+nHeight);
}


function ChkMsg(msg) {
	var sNav = (navigator.appVersion);
	var nPos = sNav.indexOf("NT 5.1; SV1")
	var nHeight

	if(nPos != -1)
		nHeight	= 250;
	else
		nHeight	= 220;
	
	var win = showModalDialog("/common_include/html/alim.htm",msg,"dialogWidth:305px; dialogHeight:" + nHeight + "px; center=yes; screenTop=yes; scroll=no; status=no; help=no;");
}

function ChkMsg_Sms(msg) {
	var sNav = (navigator.appVersion);
	var nPos = sNav.indexOf("NT 5.1; SV1")
	var nHeight

	if(nPos != -1)
		nHeight	= 250;
	else
		nHeight	= 220;
	
	var win = showModalDialog("/include/html/sms_popup.asp",msg,"dialogWidth:305px; dialogHeight:" + nHeight + "px; center=yes; screenTop=yes; scroll=no; status=no; help=no;");
}


function cn_wOpenPopUp(s_Url,sLink,sName,sWidth,sHeight)
{
	if (screen.width < 1025){
	  LeftPosition=0;
	  TopPosition=0;
	 } else {
	  LeftPosition=(screen.width)?(screen.width-450)/2:100;
	  TopPosition=(screen.height)?(screen.height-450)/2:100;
	 }

	var bellurl;
	bellurl=s_Url+"?"+sLink ;
	
	var popup=window.open(bellurl,sName,'menubar=no toolbar=no location=no status=no,left='+LeftPosition+';,top='+TopPosition+';,width=232,height=200');
	popup.focus();
}


function cn_wOpenPopUp2(s_Url,sLink,sName,sWidth,sHeight)
{
	if (screen.width < 1025){
	  LeftPosition=0;
	  TopPosition=0;
	 } else {
	  LeftPosition=(screen.width)?(screen.width-450)/2:100;
	  TopPosition=(screen.height)?(screen.height-450)/2:100;
	 }

	var bellurl;
	bellurl=s_Url+"?"+sLink ;
	
	var popup=window.open(bellurl,sName,'menubar=no toolbar=no location=no status=no,left='+LeftPosition+';,top='+TopPosition+';,width=232,height=200');
}


/*-------------------------------------------------------------------------------------------------------
- Define : ·¹ÀÌ¾î ¼Ó¼ºÁß absolute¸¦ »ç¿ë½Ã ÇØ»óµµ¿¡ ¸Â°Ô ÁÂÃøÀ§Ä¡¸¦ ±¸ÇÔ
- Para	 : nLeft(1024/768 ±âÁØÀÇ ·¹ÇÁÆ®), sID(·¹ÀÌ¾îÀÌ¸§)
- sample : SetPadding("1", 3, "0") => 001
--------------------------------------------------------------------------------------------------------*/
function SetDivLeft(nLeft, sID){
  
  var nScreenWidth 	= screen.width;
  if(nScreenWidth>1024){nLeft = (((nScreenWidth-1024)/2) + nLeft)};

  if(sID=="oLoading")
  	return nLeft;
  else
  	eval(sID).style.left = nLeft;

}


/*-------------------------------------------------------------------------------------------------------
- Define : ·ÎµùÁßÀÌ¶ó´Â ¸Þ½ÃÁö Ãâ·Â¿ë - ÆäÀÌÁö¿¡
- Para	 : nTop, nLeft, sStatus(show/hidden), sType(0,1)¼¾ÅÍÁ¤·Ä¿©ºÎ
- sample : 
--------------------------------------------------------------------------------------------------------*/
function GetLoading(nTop, nLeft, nWidth, sMsg, sStatus, sType) {
	var sHtml = "";
	
	if(sType==1){nLeft = SetDivLeft(nLeft, "oLoading")}
	
	if(sStatus=="show"){
		if(sMsg==""){sMsg="Loading...."}
		
		sHtml = sHtml + "<div style=\" POSITION: absolute;LEFT:" + nLeft + "; WIDTH: " + nWidth + "; TOP:" + nTop + "; HEIGHT:150; visibility:" + sStatus + ";\" id=\"Layer1\">";
		sHtml = sHtml + "	<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"WIDTH\">";
		sHtml = sHtml + "		<tr>";
		sHtml = sHtml + "			<td valign=\"middle\" align=\"center\">";
		sHtml = sHtml + "				<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"" + nWidth + "\">";
		sHtml = sHtml + "					<tr>";
		sHtml = sHtml + "						<td valign=\"middle\" align=\"center\" bgcolor=\"#f6f6e9\" style=\"font-color:#000000; font-family:±¼¸²,µ¸¿ò; font-size:9pt; line-height:160%;\"><font color=\"#000000\">" + sMsg + "</font></td>";
		sHtml = sHtml + "					</tr>";
		sHtml = sHtml + "					<tr>";
	 	sHtml = sHtml + "						<td valign=\"middle\" align=\"center\" bgcolor=\"#e9e7e2\"><img src=\"/images/icons/2px.gif\" border=\"0\"></td>";
		sHtml = sHtml + "					</tr>";
		sHtml = sHtml + "					<tr>";
		sHtml = sHtml + "						<td valign=\"middle\" align=\"center\"><img src=\"/images/icons/ing.gif\" border=\"0\" vspace=\"1\" WIDTH=\"" + nWidth + "\" HEIGHT=\"5\"></td>";
		sHtml = sHtml + "					</tr>";
		sHtml = sHtml + "				</table>";
		sHtml = sHtml + "			</td>";
		sHtml = sHtml + "		</tr>";
		sHtml = sHtml + "	</table>";
		sHtml = sHtml + "</div>";
		
		oLoading.innerHTML = sHtml;
	}
	else {
		oLoading.style.visibility="hidden"
	}
}


/*################################# WINDOW FUNCTION ################################################### 
----- Æû¿¡ °ü·ÃµÈÇÔ¼ö
\###################################################################################################*/
/*-------------------------------------------------------------------------------------------------------
- Define : INPUT BOX¿¡ ¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÏ°Ô ÇÑ´Ù - (sChkMsg.jsÇÔ¼ö¸¦ °°Àº ÆäÀÌÁö¿¡ ÀÎÅ©¸£µå)
- Para	 : oText - °´Ã¼¸í
- sample : <input type=text onpress='ChkNumeric(this)'
--------------------------------------------------------------------------------------------------------*/
function ChkNumeric(oText) {
  var chrTmp;
  var strTmp 		= oText.value;
  var chkAlpha 	= false;
  var resString = '';

  for (var i=0; i<=strTmp.length; i++) {
      chrTmp = strTmp.charCodeAt(i);
      if ((chrTmp <=47 && chrTmp > 31) || chrTmp >= 58) {
          chkAlpha = true;
      } else {
          resString = resString + String.fromCharCode(chrTmp);
      }
  }
  if (chkAlpha == true) {
      ChkMsg("<font color=red>¼ýÀÚ</font>¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
      oText.value = resString;
      oText.focus();
      return false;
  }
  return true;
}


/*-------------------------------------------------------------------------------------------------------
- Define : µÕ±Ù Å×ÀÌºí ¸¸µé±â
- Para	 : 
- sample : 
--------------------------------------------------------------------------------------------------------*/
function roundTable(objID) {
       var obj = document.getElementById(objID);
       var Parent, objTmp, Table, TBody, TR, TD;
       var bdcolor, bgcolor, Space;
       var trIDX, tdIDX, MAX;
       var styleWidth, styleHeight;

       // get parent node
       Parent = obj.parentNode;
       objTmp = document.createElement('SPAN');
       Parent.insertBefore(objTmp, obj);
       Parent.removeChild(obj);

       // get attribute
       bdcolor = obj.getAttribute('rborder');
       bgcolor = obj.getAttribute('rbgcolor');
       radius = parseInt(obj.getAttribute('radius'));
       if (radius == null || radius < 1) radius = 1;
       else if (radius > 6) radius = 6;

       MAX = radius * 2 + 1;
       
       /*
              create table {{
       */
       Table = document.createElement('TABLE');
       TBody = document.createElement('TBODY');

       Table.cellSpacing = 0;
       Table.cellPadding = 0;

       for (trIDX=0; trIDX < MAX; trIDX++) {
              TR = document.createElement('TR');
              Space = Math.abs(trIDX - parseInt(radius));
              for (tdIDX=0; tdIDX < MAX; tdIDX++) {
                     TD = document.createElement('TD');
                     
                     styleWidth = '1px'; styleHeight = '1px';
                     if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
                     else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
                     else if (radius > 2) {
                            if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
                            if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
                     }

                     if (styleWidth != null) TD.style.width = styleWidth;
                     if (styleHeight != null) TD.style.height = styleHeight;

                     if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
                     else if (tdIDX > Space && Space < MAX - tdIDX - 1)  TD.style.backgroundColor = bgcolor;
                     
                     if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
                     TR.appendChild(TD);
              }
              TBody.appendChild(TR);
       }

       /*
              }}
       */

       Table.appendChild(TBody);
       
       // insert table and remove original table
       Parent.insertBefore(Table, objTmp);
}

function getCookie(name) 
{ 
 var Found = false 
 var start, end 
 var i = 0 
 
 while(i <= document.cookie.length) 
 { 
	 start = i 
	 end = start + name.length 
	 
	 if(document.cookie.substring(start, end) == name) 
		 { 
			 Found = true 
			 break 
		 } 
	 i++ 
 } 
 
 if(Found == true) 
 { 
	 start = end + 1 
	 end = document.cookie.indexOf(";", start) 
	 if(end < start) 
	 end = document.cookie.length 
	 return document.cookie.substring(start, end) 
 } 
return "" 
} 

function SoEventPopup() 
{ 
	 var PopCookie = getCookie("SoEvent");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEvent_Pop.asp","","width=450,height=480,top=150,left=200");

} 
function SoEventAppPopup() 
{ 
	 var PopCookie = getCookie("SoEvent");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEvent_App_Pop.asp","","width=450,height=480,top=150,left=200");

} 

function SoLyricPopup() 
{ 
	 var PopCookie = getCookie("SoLyric");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoLyric_Pop.asp","","width=400,height=347,top=150,left=660");
}

function SoLyricAppPopup() 
{ 
	 var PopCookie = getCookie("SoLyric");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoLyric_App_Pop.asp","","width=400,height=347,top=150,left=660");
} 

function SoEvent_Musical() 
{ 
	 var PopCookie = getCookie("SoEvent");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEvent_Musical.asp","","width=450,height=525,top=150,left=660");
}

function SoEventApp_Musical() 
{ 
	 var PopCookie = getCookie("SoEvent");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEventApp_Musical.asp","","width=450,height=525,top=150,left=660");
}

function SoEvent_Zion() 
{ 
	 var PopCookie = getCookie("SoEvent");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEvent_Zion.asp","","width=550,height=520,top=150,left=660");
}
function SoEvent_Hp() 
{ 
	 var PopCookie = getCookie("SoEventHp");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/event/Popup/SoEvent_Hp.asp","","width=550,height=520,top=150,left=460");
}

function popup_notice() 
{ 
	 var PopCookie = getCookie("popup_notice");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/Popup/popup_notice.asp","","width=420,height=340,top=150,left=460");
}

function mnetpopup() 
{ 
	 var PopCookie = getCookie("mnetmusic");
	 if (PopCookie != "done") 
	 window.open("http://www.songsari.com/popup/mnetmusicopen.asp","","width=420,height=340,top=150,left=460");
}