﻿// common.js 1.0.0.
//--------------------------- swapimage & image_preload ---------------------------//
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_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_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_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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//--------------------------- subnavi_bg ---------------------------//
function subnavi_bg(){
    $("#contents-left #subnavi dd > ul > li:odd").addClass("odd");
}
//--------------------------- ie6_hover ---------------------------//
function ie6_hover(){
    $(":button, :submit, :hidden").hover(function(){$(this).addClass("btn-hover");}, function(){$(this).removeClass("btn-hover");});
}
//--------------------------- copyright year ---------------------------//
function c_year(startYear){
    var myYear=(new Date()).getFullYear();
    if(startYear != myYear){
        document.write("-" + myYear);
    }
}
//--------------------------- search text reset ---------------------------//
function header_search_reset(){
    $("#header-search input:text").focus(function(){
                                                    $(this).val("");
                                                    });
}
//--------------------------- add target ---------------------------//
function init_target(){
    var obj = document.getElementsByTagName("a");
    for(var i=0; i<obj.length; i++){
        if(obj[i].getAttribute("rel") == "blank"){
            obj[i].setAttribute("target", "_blank");
        }
    }
}
//--------------------------- video_list_bg ---------------------------//
function video_list_bg(){
        $("div.video div.video-list #title-list div.title-wrapper:even").addClass("even");
        $("div.video div.video-list #title-list div.title-wrapper:odd").addClass("odd");
        $("div.video div.video-list #title-list div.title-wrapper div.title:even").addClass("even");
        $("div.video div.video-list #title-list div.title-wrapper div.title:odd").addClass("odd");
}
//--------------------------- video_lineup_bg ---------------------------//
function video_lineup_bg(){
        $("#lineup #lineup-list div.lineup-wrapper dl.lineup:even dt").addClass("even");
}
//--------------------------- product-list ---------------------------//
function product_list(){
        $("#contents-right div.howto-product table#maker-list tr:last td").addClass("last");
}
//--------------------------- shop_list ---------------------------//
function shop_list(){
        $("#contents-right div.howto-shop table.shop-list tr:not(.header, .pref):odd").addClass("odd");
}
//--------------------------- basic_service_list ---------------------------//
function basic_service_list(){
    if($("div.basic-index").length){
        $("#service-list div.service-wrapper dl.service:even dt").addClass("even");
    }
}
//--------------------------- btn_speedtest_hover ---------------------------//
function btn_speedtest_hover(){
    var tmp = '<a href="javascript:void(0)" alt="スピードテスト" onclick="MM_openBrWindow(';
    var tmp2 = tmp + "'../howto/speedtest.html','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes')";
    tmp = tmp2 + '" title="スピードテスト">スピードテスト</a>'
    $("#stest").css({"position":"absolute","left":"515px","top":"224px"}).append(tmp);
    $("#stest a").hover(function(){$(this).css("background","url(../img/guide/btn_speed_s.gif) no-repeat 0px -29px")},function(){$(this).css("background","url(../img/guide/btn_speed_s.gif) no-repeat 0px 0px")});
}
//--------------------------- init ---------------------------//
$(function(){
           init_target();
           subnavi_bg();
           ie6_hover();
           header_search_reset();
           btn_speedtest_hover();
           if($("div.video-lineup").length){ video_lineup_bg();}
           if($("div.video-index").length){MM_preloadImages('../img/video/btn_toppage_over.gif');$("div.video-index p.totop a img").hover(function(){$(this).attr("src","../img/video/btn_toppage_over.gif")},function(){$(this).attr("src","../img/video/btn_toppage.gif")});}
           if($("div.video-list").length){MM_preloadImages('../img/video/btn_toppage_over.gif');video_list_bg();$("div.video-list p.previous a img").hover(function(){$(this).attr("src","../img/video/btn_toppage_over.gif")},function(){$(this).attr("src","../img/video/btn_toppage.gif")});}
           if($("div.video-title").length){MM_preloadImages('../img/video/btn_toppage_over.gif');$("div.video-title p.previous a img").hover(function(){$(this).attr("src","../img/video/btn_previous_over.gif")},function(){$(this).attr("src","../img/video/btn_previous.gif")});} 
           if($("div.howto-product").length){MM_preloadImages('../img/howto/btn_back_maker_list_over.gif');$("div.howto-product p > a > img").hover(function(){$(this).attr("src","../img/howto/btn_back_maker_list_over.gif")},function(){$(this).attr("src","../img/howto/btn_back_maker_list.gif")});}
});

