/**
 * 
 * 入学内祝いネットのJavaScript 外部ファイル
 * 
 * 
 * 作成日: 2006.06.09 
 * 作成者: 藤井
 * 更新日: $Id: main.js,v 1.5 2007/12/13 21:15:59 yfujii Exp $ 
 * 更新者: $Author: yfujii $
 * 
 * Copyright fsstore All rights reserved.
 *
 */


/**
 * アクセスログを取得してから、引数の画像を表示する
 */
function showimage(page,pic,comment){
/*
    document.write("<img src='/cgi-bin/showimage.cgi?");
    document.write("p_id=" + page + "&p_show_image="+ pic + "&");
    document.write("p_referrer="+document.referrer+"&");
    document.write("p_width="+screen.width+"&");
    document.write("p_height="+screen.height+"&");
    document.write("p_color="+screen.colorDepth+"'");
    document.write("alt='"+ comment +"'");
*/
}

/**
 * お気に入りに追加する
 */
function addFavorite(page){

    if (window.external) {
       //どのページでクリッククされたかを記録
       getAccessLog("addFavorite_" + page);

       var addURL = location.protocol + '//' + location.host + location.pathname;

       window.external.AddFavorite(addURL,'入学内祝いネット');

    } else {
        alert("申し訳ありません、この機能は、Internet Explorer 4.0 以降でのみ使用可能です。");
    }

}

/**
 * アクセスログを取得する
 */
function getAccessLog(page){
    img = new Image(1,1);
    img.src =  "/cgi-bin/showimage.cgi?p_id=" + page + "&p_show_image=spacer.gif"
             + "&p_referrer=" + document.referrer
             + "&p_width="    + screen.width
             + "&p_height="   + screen.height
             + "&p_color="    + screen.colorDepth ;
}

/**
 * ページID（ページのPATHから.htmlを省いたもの）を返します。
 */
function getPageID(){

    //初期値は、index
    var myPageID = 'index';

    var start = location.pathname.lastIndexOf("/") + 1;
    var end = location.pathname.lastIndexOf(".");

    if(end != -1){
        myPageID = location.pathname.substring(start,end);
    }

    return myPageID;

}

/**
 * 商品サンプルを小窓で表示します。
 */
function openSample(code){

      w = 600;
      h = 450;
      x = (screen.width - w) / 2 ;
      y = 20;

      win = window.open("/products/sample_shokuroman.html","exchangeSample",
                  "resizable=yes,scrollbars=no,left="+x+",top="+y+",width="+w+",height="+h+"");

      win.code = code;
      win.focus(); 

}

/**
 * 別小窓を閉じる
 */
function closeSample(page){

    setTimeout("parent.close()",100);
}

/**
 * Submit時に必須項目の入力をチェックする
 */
function entryCheck(theElement,msg,focusElement){

    if(theElement.value == null || theElement.value == ""){
       alert(msg);
       focusElement.focus();
       theElement.focus();
       return false;
    }

   return true;

}