﻿var Pagetop={
    fnc:function(){
        $("[Pagetop]").click(function(e){
            e.preventDefault();
            var hash = this.hash;
            if(!hash || hash == "#") return false;
            $($.browser.safari ? 'body' : 'html' , top.document).animate({scrollTop: $(hash).offset().top}, 500, "swing");
        });
    }//END fnc
}

$(function(){
    Pagetop.fnc();
    rollover();
});
/* !stack ------------------------------------------------------------------- */
jQuery(document).ready(function($) {
    rollover();
    localNav();
});

/* !rollover ---------------------------------------------------------------- */
var rollover = function(){
    var suffix = { normal : '_no.', over   : '_on.'}
    $('a.over, img.over, input.over').each(function(){
        var a = null;
        var img = null;

        var elem = $(this).get(0);
        if( elem.nodeName.toLowerCase() == 'a' ){
            a = $(this);
            img = $('img',this);
        }else if( elem.nodeName.toLowerCase() == 'img' || elem.nodeName.toLowerCase() == 'input' ){
            img = $(this);
        }

        var src_no = img.attr('src');
        var src_on = src_no.replace(suffix.normal, suffix.over);

        if( elem.nodeName.toLowerCase() == 'a' ){
            a.bind("mouseover focus",function(){ img.attr('src',src_on); })
             .bind("mouseout blur",  function(){ img.attr('src',src_no); });
        }else if( elem.nodeName.toLowerCase() == 'img' ){
            img.bind("mouseover",function(){ img.attr('src',src_on); })
               .bind("mouseout", function(){ img.attr('src',src_no); });
        }else if( elem.nodeName.toLowerCase() == 'input' ){
            img.bind("mouseover focus",function(){ img.attr('src',src_on); })
               .bind("mouseout blur",  function(){ img.attr('src',src_no); });
        }

        var cacheimg = document.createElement('img');
        cacheimg.src = src_on;
    });
};
/* !localNav ---------------------------------------------------------------- */
var localNav = function(){
    var navClass = $('#ON_vitamin,#ON_skin_topics,#ON_lineup,#ON_knowledge,#ON_quiz,#ON_def,#ON_present,#ONCategory,#ONreference_faq,#ON_cm,#ON_index,#ON_gatget').attr('class');
    var parent = $("#lnavi");
    var routing = [];
    $("ul ul", parent).hide();
    if( navClass.indexOf("lDef") < 0 ){
        routing[0] = navClass.match(/l[\d]+_[\d]+_[\d]+/);
        routing[1] = navClass.match(/l[\d]+_[\d]+/);
        routing[2] = navClass.match(/l[\d]+/);
        if( routing[0] ){ routing[0].push(routing[0][0].match(/[\d]+/g)) };
        if( routing[1] ){ routing[1].push(routing[1][0].match(/[\d]+/g)) };
        if( routing[2] ){ routing[2].push(routing[2][0].match(/[\d]+/g)) };
        if( routing[0] != null ){
            var e = $("a.lnav"+routing[0][1][0]+'_'+routing[0][1][1]+'_'+routing[0][1][2], parent);
                e.addClass('current');
                e.parent().parent().show()
                 .parent().parent().show();
        }else if( routing[1] != null ){
            var e = $("a.lnav"+routing[1][1][0]+'_'+routing[1][1][1], parent);
                e.addClass('current');
                e.next().show();
                e.parent().parent().show();
                e.parent().parent().prev().addClass("parent");
        }else if( routing[2] != null ){
            var e = $("a.lnav"+routing[2][1], parent);
                e.addClass('current');
                e.parent().next().show();
        }else{
        }
    }
}
/* !Block Hover ------------------------------------------------------------- */
$(function(){
	$("#bnr_top01").click(function(){
		window.location=$(this).find("a").attr("href");
		return false;
	});
	$('#bnr_top01').hover(function() {
		$(this).addClass('hover');
	},function() {
		$(this).removeClass('hover');
	});
});


var Popup={
  init:{
	  w:null
  },
  set:function(thisurl,type){
	  if(type=="form") Popup.init.w=window.open(thisurl,'popupwindow','menubar=no,scrollbars=yes,resizable=yes,width=1000,height=650');
	  Popup.init.w.focus();
  },//END set
  gomain:function(thisurl,type){
	  if(opener){
		  opener.location.href=thisurl;
		  window.blur();
	  }else{
		  location.href = thisurl;
	  }
  }//END gomain
}



