function OnBtn(obj){
    obj.style.color='#1b7dd7';
}

function OffBtn(obj){
    obj.style.color='#004a8e';
}

function OffBtn2(obj){
    obj.style.color='#545454';
}

function btn_go(url)
{
  if(url != "")  {
    location.href=url;
  }
    
}


function Sjlogout()
{
  if(confirm('정말 로그아웃 하시겠습니까?'))
  {
    var UDIR = window.location.protocol+'//'+window.location.hostname+'/_Template/Ms_Main/';
    var Result =  Ajax.exec(UDIR+'Logout.php');
    
	document.location.replace('/');
	if(IE_) window.event.returnValue=false;
    
    return false;
  
  }
  
  
}
                                
           

var Main =
{
    UDIR : window.location.protocol+'//'+window.location.hostname+'/_Template/Ms_Main/',
    TopMenuEvent : function()
    {
       
        var Images = $('trm_bottom_menu').getElementsByTagName('img');
        for(var i=0; i < Images.length; i++)
        {
            var img = Images[i];
            if(img.parentNode.tagName == 'A')
            {
               
               
                if((/\/navi\//).test(img.src))
                {
                   Main.setSubMenus(img);
                   continue;
                } 
               
               
                
                   var Box = img.parentNode.parentNode;
                   
                   Box.style.position = "relative";
                   Box.style.height = "64px";
                   Box.style.width = UI.getObjSize(img).w+"px";
                   Box.style.overflow = "visible";
                   
                   var Sub =  $('tnr_navi_'+img.id);
                   if(Sub)
                   {
                     Sub.style.position = 'absolute';
                     Sub.style.top = '60px';
                     //Sub.style.width = '400px';
                   }
                   
                   Main.chkURL(img);
                   
                   Box.onmouseover = function ()
                   {
                      Main.showSubMenus(this);
                   }
                   .bind(img);
                   
             
            }
            
        }
      
    },
    
    chkURL : function (Img)
    {
         var Tag = Img.parentNode;
         
        
         var Href = Tag.href.replace(/http\:\/\//, "");
         var PURL_Array = Href.split('/');
         
         
         var PURL = '';
         
         
         for(var i=0; i < 2; i++)
         {
            if(PURL_Array[i]) PURL+= PURL_Array[i] + '/'
         }
         
         var Href = PURL.toUpperCase().replace(/\//g, "").replace(/\:/g, "");
         var DHref = document.location.href.toUpperCase().replace(/\//g, "").replace(/\:/g, "");
         
         var Test = eval("(/"+Href+"/).test(\""+DHref+"\");");
         if(Test)  Main.showSubMenus(Img);
         
    },
    
    
    showSubMenus : function (Img)
    {
      
       if(Main.selectedImg) 
       {
           Main.hideSubMenus(Main.selectedImg);
       }
       
       if(!(/_on\.gif$/).test(Img.src))
       {
            Img.src = Img.src.replace((/([0-9a-zA-Z\/\:\._]*)(\.gif)$/), "$1_on$2");
       }
         
         
         var Sub =  $('tnr_navi_'+Img.id);
         
         if(Sub)
         {
             Sub.style.display = 'block';
             var SubLeft  = UI.getOffsetPos(Sub).x;
             SubLeft = isNaN(SubLeft) ? 0 : SubLeft;
         }
         
         Main.selectedImg = Img;
         
    },

    hideSubMenus : function (Img)
    {
        Img.src = Img.src.replace((/([0-9a-zA-Z\/\:\._]*)(_on\.gif)$/), "$1.gif");
        if($('tnr_navi_'+Img.id))
        $('tnr_navi_'+Img.id).style.display = 'none';
    },
        
    
    setSubMenus : function (Img)
    {
          if((/\.gif$/).test(Img.src))
          {
                Img.onmouseover = function ()
                {
                    this.src = this.src.replace((/([0-9a-zA-Z\/\:\._]*)((_on|_off)\.gif)$/), "$1_on.gif");
                };
                
                Img.onmouseout = function ()
                {
                    this.src = this.src.replace((/([0-9a-zA-Z\/\:\._]*)((_on|_off)\.gif)$/), "$1_off.gif");
                };
             
          }
                    
        
        
    }   
    
}

var Login = 
{
    UDIR : window.location.protocol+'//'+window.location.hostname+'/_Template/Ms_Main/',
    needLogin : false,
    initLogin : function ()
    {
       //Login.setLogout();
       Login.setLoginForm();
       
        
    },
    
    ResultOk : null,
    
    sendForm : function (F)
    {
        
        
        if(!form.checkValue(F.USER_ID, 1, '아이디를 입력해 주세요')) return false;
        if(!form.checkValue(F.USER_PASSWD, 1, '비밀번호를 입력해 주세요')) return false;
        
        var LoginPage = Config.SecureServer + "/secureLogin.php";
        F.action = (F.secure.checked) ? 'https://'+LoginPage : 'http://'+LoginPage;
        F.RURL.value = Login.UDIR + 'LoginCheck.php';
      
       
       return true;
	
	
        
    },
    
    
    loginResult : function(Result)
    {
      if(!Result) alert('아이디 또는 비밀번호를 잘못 입력 하셨습니다.');
      else
      {
    
           switch(Result)
           {
               
               
               case "AUTH_N" :
               // 주민번호 없음
                   
                    // alert('실명확인이 이루어 지지 않았습니다. 실명확인 페이지로 이동합니다');
                    var msg = "아직 실명인증을 받지 않으셨네요^^\n실명인증과 기본정보 변경을 해주셔야 뮤직쉐이크닷컴 이용이 가능합니다.\n(실명인증을 받지 않을 경우 이용에 제한이 있으니 꼭 해주세요.)";
                    alert(msg);
                    document.location.replace(' /MyMusicShake/My_Information/Basic_Information/ ');
                    return;
                   
               break;
               
               
               
               default : 
               
                      if(isFunction(Login.ResultOk))
                      { 
                            Login.ResultOk();
                            return false;
                      }
                   
                   
                    var Param = 
                    {
                        'onComplete' : Login.setLogout
                    }
                   
                    AutoRun.setDocument($('trm_top_login'), Param , Login.UDIR + 'UserLoginInfo.php');
                    AutoRun.setDocument($('trm_bottom_info'), {} , Login.UDIR + 'UserLogin.php');
                   
               break;
               
             }
           
      }
       
    },
    
    setLoginForm : function ()
    {
       if(!$('USER_ID')) return false;
       
        $('USER_ID').value = $('USER_PASSWD').value = '';

        $('USER_ID').onfocus = function ()
        {
            this.className = 'top_tbox';
        }
        
        $('USER_PASSWD').onfocus = function ()
        {
            this.className = 'top_tbox';
        }
        
        $('USER_ID').onblur = function ()
        {
            if(!this.value) this.className = 'top_id_tbox';
        }
      
        $('USER_PASSWD').onblur = function ()
        {
            if(!this.value) this.className = 'top_pw_tbox';
        }
    },
	
	
	getLogin : function()
	{
		var Result = Ajax.exec(getComponentURL('Musicshake')+'Login.php',{'CHECK' : 'LOGIN'} );
		if(Result.text == 'OK')
			return true;
		else
			return false; 
	}
     
    
    
}


var Listen =
{
    
    chView : function (ID, Obj)
    {
       
        if(Obj.id != 'current')
        {
            
            $('song_recommend').style.display = 'none';
            $('song_listen').style.display = 'none';
            $('song_Faim').style.display = 'none';
            $('song_comment').style.display = 'none';
            $('current').id = '';
            Obj.id = 'current';
            
            $(ID).style.display = 'block';
        }
        
        
    }
    
}


var  Movie = 
{
 
    setOn : function (Obj, Num)
    {
      $('mbb_gb_lm_on').id  = "mbb_gb_lm_off";
      $(Obj).id = "mbb_gb_lm_on";
         
         switch(Num)
         {
			case 2 :
            Movie.showCreate();
			$('MoreMore').href = "/Guide/Beginner/";
			break;
             
             case 3 :
             Movie.showStar();
             $('MoreMore').href = "/Guide/Beginner/";
             break;
             
             default :
              Movie.showIntro();
              $('MoreMore').href = "/Guide/Beginner/";
             break;
         } 
    },
 
    showIntro : function () 
    { 
        flashPlayer.showPlayer($('mbb_gb_right_pic'), 
       	{
       		playmode : 'manual',
       		// movieurl : 'http://www.youtube.com/v/UJ1GHLrYEZA&hl=ko&fs=1&border=1',
		movieurl : 'http://www.youtube.com/v/rTAQc_0Wwmg&hl=ko_KR&fs=1&rel=0&border=1',
       		movietitle : '뮤직쉐이크 UCC 뮤직쉐이크 아이폰 어플 런칭!'
       	});
                              
    },
    
    showCreate : function () 
    { 
        flashPlayer.showPlayer($('mbb_gb_right_pic'), 
       	{
       		playmode : 'manual',
       		movieurl : 'http://www.youtube.com/v/BR4E7YvlwFk&hl=ko&fs=1&rel=0&border=1',
       		movietitle : '마리서사 Just My Love'
       	});
                              
    },
    
    showStar : function () 
    { 
        flashPlayer.showPlayer($('mbb_gb_right_pic'), 
       	{
       		playmode : 'manual',
       		movieurl : 'http://www.youtube.com/v/TR3ELA-4UT8&hl=ko&fs=1&rel=0&border=1',
       		movietitle : '자랑곡퍼가기'
       	});
                              
    }
    
    
    
}

addEvent(window, 'load', Main.TopMenuEvent);
addEvent(window, 'load', Login.initLogin);
