
//-------------¸Þ´º °ü·Ã----------------------------------------------------------------------------------------------//

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_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; }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//-------------¸Þ´º °ü·Ã----------------------------------------------------------------------------------------------//






function OpenWindow(url, width, height) {
    window.open(url, "ContentWin", "left=" + ((window.screen.availWidth - width) / 2) + ",top=" + ((window.screen.availHeight - height) / 2) + ",width=" + width + ",height=" + height + ",directories=no,toolbar=no,status=no,resizable=no,scrollbars=no");
}

function trim (strSource) {
	re = /^[\s¡¡]+|[\s¡¡]+$/g;

	return strSource.replace(re, '');
}

function ltrim (strSource) {
	re = /^[\s¡¡]+/g;

	return strSource.replace(re, '');
}

function rtrim (strSource) {
	re = /[\s¡¡]+$/g;

	return strSource.replace(re, '');
}



function fcEscape(s)
{
	s = s.split("<").join("&lt;").split(">").join("&gt;")
	var ch;
	var val;
	var ret = "";
	var len = s.length;

	for (var i = 0; i < len ; i++)
	{
		val = s.charCodeAt(i);
		ch = val.toString(16);

		if (val < 0x80)
		{
			ret += "%" + (ch.length < 2 ? "0" + ch : ch);
		}
		else if (val <= 0xFF)
		{
			ret += "%u00" + (ch.length < 2 ? "0" + ch : ch);
		}
		else
		{
			ret += "%u" + (ch.length < 4 ? "0" + ch : ch);
		}
	}
	return ret;
}


function GFcActiveXWrite(s) {
    document.write (s);
}

////////////////////////////////////////////////////////////////////////////////
// ÀÚµ¿ ÆË¾÷ Â÷´ÜµÉ °æ¿ì ÇØÁ¦ ¾È³» ¸ðµâ µé¾î ÀÖ´Â ÆË¾÷ ¶ç¿ì±â
// function GFcOpenWindow(url, target, opt, title)
// url : ÆË¾÷ ÆäÀÌÁö URL
// target : ÆË¾÷ À©µµ¿ì target
// opt : ÆË¾÷ À©µµ¿ì feature
// title : Â÷´ÜµÇ¾úÀ» °æ¿ì ¾È³»¸¦ À§ÇÑ ÆË¾÷ Å¸ÀÌÆ²
// return value : ¼º°øÇÏ¸é ÆË¾÷ À©µµ¿ì °´Ã¼, ½ÇÆÐÇÏ¸é null
// ÀÛ¼ºÀÚ : arcanian (2004-09-16)
////////////////////////////////////////////////////////////////////////////////
function GFcOpenWindow(url, target, opt, title)
{
	var win = window.open(url, target, opt);
	if (win == null)
	{
		var popup = new GFcCreatePopup(url, target, opt, (title ? title : ""));
		if (GFcGetCookie("fcpopupguide") == "")
		{
			if (!g_Popup.confirmed)
			{
				g_Popup.confirmed = true;
				if (document.body)
					GFcPopupConfirm();
				else if (window.addEventListener)
					window.addEventListener("load", GFcPopupConfirm, false);
				else if (window.attachEvent)
					window.attachEvent("onload", GFcPopupConfirm);
			}
		}
		else
		{
			if (document.body)
				GFcDisplayPopupIcons();
			else if (window.addEventListener)
				window.addEventListener("load", GFcDisplayPopupIcons, false);
			else if (window.attachEvent)
				window.attachEvent("onload", GFcDisplayPopupIcons);
		}
	}
	return win;
}

function openPopup(strwinName,strUrl,intWidth,intHeight,ynResize)
{
	var left = (window.screen.availWidth-intWidth) >> 1;
	var top = (window.screen.availHeight-intHeight) >> 1;
	var opt = "left=" + left + ",top=" + top + ",width=" + intWidth + ",height=" + intHeight + ",resizable=" + ynResize;

	return GFcOpenWindow(strUrl, strwinName, opt);
}

function HTMLDecode(strHtml) {
	var strRetVal = "";

	strRetVal = strHtml.replace(/&gt;/gi, ">");
	strRetVal = strRetVal.replace(/&lt;/gi, "<");
	strRetVal = strRetVal.replace(/&quot;/gi, "\"");
	strRetVal = strRetVal.replace(/&amp;/gi, "&");

	return strRetVal;
}



//////////////////////////////////////////////////////////////////////////////////////////////
// String ±æÀÌ¸¦ ±¸ÇÏ´Â Script By Moon
//
//      * CheckStrLen(obj, MaxLen, ErrorMessage)
//	    - obj : text or textarea object
//		--> MaxLen º¸´Ù ¹®ÀÚ¿­ÀÌ ÂªÀ¸¸é true, ±æ¸é false ¸®ÅÏ
//      - FieldName : Error°¡ ¹ß»ýÇÑ ÇÊµåÀÇ ÀÌ¸§
//		--> "" ·Î ³ÖÀ¸¸é..Alert ¶ç¿ìÁö ¾ÊÀ½. (ºñ¿ì¸é ¾ÈµÊ..)
//////////////////////////////////////////////////////////////////////////////////////////////
function CheckStrLen(obj, MaxLen, FieldName) {
	var i, len=0;
// added by ayasiee
	if (typeof obj == "undefined") {
		return true
	}
// added by ayasiee
	var s = obj.value;

	// String ±æÀÌ¸¦ ±¸ÇÏ´Â ºÎºÐ..
	for(i=0;i < s.length; i++) (s.charCodeAt(i) > 255)? len+=2:len++;

	// ±æÀÌ È®ÀÎ.
	if (MaxLen < len) {
		if (FieldName != "") alert(FieldName + "Àº(´Â) " + MaxLen + "ÀÚ¸¦ ³ÑÀ» ¼ö ¾ø½À´Ï´Ù(ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)");
		obj.focus();
		return false;
	}
	return true;
}


var xmlHttp;

function getChart(to,w)
{


	if (w==1)
	{
		decreaseWeek(to);
	}
	else
	{
		increaseWeek(to);
	}


	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 

	var tyear	= document.getElementById("year"+to).innerHTML;
	var tmonth	= document.getElementById("month"+to).innerHTML;
	var tweek	= document.getElementById("week"+to).innerHTML;
	var url = "SoMusicList.asp?ctype="+to+"&cyear="+tyear+"&cmonth="+tmonth+"&cweek="+tweek;

	//alert(url);
	
	if (to==1){
		xmlHttp.onreadystatechange=stateChanged1;
	}
	else{
		xmlHttp.onreadystatechange=stateChanged2;
	}


	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

} 


function getChartApp(to,w)
{


	if (w==1)
	{
		decreaseWeek(to);
	}
	else
	{
		increaseWeek(to);
	}


	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 

	var tyear	= document.getElementById("year"+to).innerHTML;
	var tmonth	= document.getElementById("month"+to).innerHTML;
	var tweek	= document.getElementById("week"+to).innerHTML;
	var url = "/app/top50list.asp?ryear="+tyear+"&rmonth="+tmonth+"rcweek="+tweek;

	//alert(url);
	
	if (to==1){
		xmlHttp.onreadystatechange=stateChanged1;
	}
	else{
		xmlHttp.onreadystatechange=stateChanged2;
	}


	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

} 



function stateWebLink() 
{ 
	if (xmlHttp.readyState==4){ 
		if (xmlHttp.status == 200){
			alert("¼º°ø");	
		}
		else{
			alert("¼Û»ç¸® ¾îÇÃ¸®ÄÉÀÌ¼ÇÀÌ ¼³Ä¡µÇ ÀÖÁö ¾Ê½À´Ï´Ù.\n¼³Ä¡ÈÄ À¥¸µÅ© ´Ù¿î·Îµå°¡ °¡´ÉÇÕ´Ï´Ù.");
		}

	}
}


function stateChanged1() 
{ 
	if (xmlHttp.readyState==4){ 
		if (xmlHttp.responseText.length!=0){ 
		document.getElementById("chart1").innerHTML=xmlHttp.responseText;
		}
	}
}


function stateChanged2() 
{ 
	if (xmlHttp.readyState==4){ 
		if (xmlHttp.responseText.length!=0){ 
		document.getElementById("chart2").innerHTML=xmlHttp.responseText;
		}
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}



//ÁÖ °¨¼Ò
function decreaseWeek(to){

	if (document.getElementById("week"+to).innerHTML != "1"){
		document.getElementById("week"+to).innerHTML =  parseInt(document.getElementById("week"+to).innerHTML) -1;
	}
	else{
		if (document.getElementById("month"+to).innerHTML != "1"){
			document.getElementById("month"+to).innerHTML =  parseInt(document.getElementById("month"+to).innerHTML) -1;
			document.getElementById("week"+to).innerHTML =  "5";
		}
		else{
			document.getElementById("year"+to).innerHTML =  parseInt(document.getElementById("year"+to).innerHTML) -1;
			document.getElementById("month"+to).innerHTML =  "12";
			document.getElementById("week"+to).innerHTML =  "5";
		}
	}
}

//ÁÖ Áõ°¡
function increaseWeek(to){

	if (document.getElementById("week"+to).innerHTML != "5"){
		document.getElementById("week"+to).innerHTML =  parseInt(document.getElementById("week"+to).innerHTML) + 1;
	}
	else{
		if (document.getElementById("month"+to).innerHTML != "12"){
			document.getElementById("month"+to).innerHTML =  parseInt(document.getElementById("month"+to).innerHTML) +1;
			document.getElementById("week"+to).innerHTML =  "1";
		}
		else{
			document.getElementById("year"+to).innerHTML =  parseInt(document.getElementById("year"+to).innerHTML) +1;
			document.getElementById("month"+to).innerHTML =  "1";
			document.getElementById("week"+to).innerHTML =  "1";
		}
	}
}




function WebLink(URL)
{
	var isSsrIsInt;
	 isSsrIsInt = webLinkReady();

	if (isSsrIsInt == 1) {
		location.href=URL;
	} else if (isSsrIsInt == 0) {
		ssrDoInstall()
	}else if (isSsrIsInt == -1) {
		alert("activeX¸¦ ¼³Ä¡ÇØ¾ß »ç¿ë°¡´ÉÇÕ´Ï´Ù.");
	}	
	
}

function WebLinkApp(URL)
{
	location.href=URL;
}



function WebLink2(url)
{


	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

//	var url = "sttp:/adjhfjhfdhljfadlhafsdhl"
//	var url = "http://dev2.songsari.com/MusicChart/SoMusicChart.aspa";
	
	xmlHttp.onreadystatechange=stateWebLink;


	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

} 



//-- app¿¡¼­ ·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ÆäÀÌÁö¸¦ ¿ÀÇÂ ÇÒ¶§ »ç¿ëÇÒ ÇÔ¼ö
//-- ²À!! ÀÌ ÇÔ¼ö »ç¿ë¹Ù¶÷. app¿¡¼­ ÇÔ¼ö ÀÌ¸§À¸·Î Ã¼Å©ÇÏ¿© »ç¿ëÇÏ±â ¶§¹®
//-- Jeunet(2007/10/11)
function openLogInWin(tURL) {

	alert(escape(tURL));
	//location.href = tURL;
	window.open(escape(tURL))
}



function goMenu(no) {
	if(no==1) {
	location.href="/introduce/SoIntroduce.asp?mtype=1";
	}
	if(no==11) {
	location.href="/introduce/SoIntroduce.asp?mtype=1";
	}
	if(no==12) {
	location.href="/introduce/SoFiltering.asp?mtype=2";
	}
	if(no==13) {
	location.href="/customercenter/SoHelp.asp?mtype=3";
	}
	if(no==14) {
	location.href="/Download/SoDownLoad.asp?mtype=4";
	}
	if(no==2) {
	location.href="/smagazine/index.asp";
	}
	if(no==3) {
	location.href="/membership/SoMusicMembership.asp";
	}
	if(no==4) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=11&Calev3ID=0";
	}
	if(no==41) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=11&Calev3ID=0";
	}
	if(no==42) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=12&Calev3ID=0";
	}
	if(no==43) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=13&Calev3ID=0";
	}
	if(no==44) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=14&Calev3ID=0";
	}
	if(no==45) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=16&Calev3ID=0";
	}
	if(no==46) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=15&Calev3ID=0";
	}
	if(no==47) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=17&Calev3ID=0";
	}
	if(no==48) {
	location.href="/sharebbs/ShareBBSList.asp?Calev1ID=1&Calev2ID=18&Calev3ID=0";
	}
	if(no==5) {
		location.href="/event/SoEvent.asp?mtype=1";
	}
	if(no==51) {
		location.href="/event/SoEvent.asp?mtype=1";
	}
	if(no==52) {
		alert("ÀÌº¥Æ® ´çÃ· ³»¿ªÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
	}
	if(no==53) {
		location.href="/event/coupon/SoCouponInputForm.asp?mtype=3";
	}
	if(no==54) {
		location.href="/event/SoFreeCharge.asp?mtype=4";
	}
	if(no==6) {
	location.href="/customercenter/bbs/SoBBSList.asp?mtype=1&calev1id=1&calev2id=1&calev3id=0";
	}
	if(no==61) {
	location.href="/customercenter/bbs/SoBBSList.asp?mtype=1&calev1id=1&calev2id=1&calev3id=0";
	}
	if(no==62) {
	location.href="/customercenter/faq/Sofaq.asp?mtype=2";
	}
	if(no==63) {
	location.href="/customercenter/bbs/SoBBSList.asp?mtype=3&calev1id=1&calev2id=2&calev3id=0";
	}
	if(no==64) {
	window.open('http://copyright.songsari.com/','','','','');
	}
}


function MusicDownConfirm(weblinkPara)
{
	if(confirm('¼±ÅÃÇÏ½Å °îÀ» ´Ù¿î·Îµå ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		WebLink(weblinkPara);
		//return;
	}
	//return;
}

