//revision:1.17
$G['Column'] = false;
$G['PageType'] = 2;
$G['Filter'] = false;
$G['ImgSearch'] = true;
$G['MarginTop'] = true;
$G['PageMode'] = 5;

var ___rnd = 0;
var picArray = new Array();

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
//ログ用
var logLines = 0;
function appendLog( str )
{
    if ($id('log'))
    {
        var logObj = $$("log");
        logObj.options[logLines] = new Option( logLines + ': ' +str, logLines);
        logLines++;
    }
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function ibkeyword_search(key){
    //for Keyword Seach
    document.ibform.k.value = key;

    document.ibform.it.value = "0";

    document.ibform.p.value = "";
    document.ibform.n.value = "";
    document.ibform.md.value = "";
    document.ibform.id.value = "";
    document.ibform.rj.value = "";
    document.ibform.rjp.value = "";

    document.ibform.submit();
}

// 類似検索ウィンドウに値を渡す時に途中、ダイアログを出すか出さないか
function resetRuijiId( _value )
{
    resetRuijiIdMain( _value )
    $('search_main02').focus();
    /*
    if( !document.cookie.match(/mbiruijiprompt/) && _value != "")
    {
        // クッキーに値がなければ
        ruijiInfoShow( _value );    // 確認ダイアログ表示
        return false;
    }
    else
    {
        // クッキーに値があればoffが書き込まれてるはずなので、類似ｾｯﾄJavaスクリプト呼び出し
        resetRuijiIdMain( _value )
    }
    */
}


//類似枠に値をセット
function resetRuijiIdMain( _value )
{
    if ( $num(_value) && _value.length == 11 )
    {
        $G['Ruiji'] = '1';
        $$('search_option_btn_open').attr('src','/img/font/btn_search_op_close.gif');
        $$('search_option_btn_open').attr('alt','検索オプションを閉じる');
        $$('search_option_box').on();
        floatWindowPointerChecker();

        //document.dispform.id.value=_value;
        $('search_ruiji_num').value = '｢'+ _value + '｣で類似画像検索';
        ruijiSampleShowImage(_value);
    }
    else
    {
        ruijiSampleCloseImage();
        if( $num( $('search_ruiji_num').value) && $('search_ruiji_num').value.length == 11 )
        {
            $('search_ruiji_num').value = _value;
            if(_value == '' ) $G['Ruiji'] = '';
        }
        else
        {
            //document.dispform.id.value='';
            $('search_ruiji_num').value = '';
        }
    }

    return false;
}

function submitKeywordNavigation()
{
    var obj = document.keynavi;
    var word = '';
    for (var i=0;i<obj.length;i++ )
    {
        if(obj[i].type == 'radio') {
            if (obj[i].checked == true) {
                word += ' ' + obj[i].value;
            }
        }
    }
    obj.k.value = word
    keynavi.submit();
}

/*クッキーからキーワードナビゲーション機能の表示・非表示設定を判別する*/
function isKeywordNavigation()
{
    if( document.cookie.match(/mbikeynavi=off/) )
        return false;
    else
        return true;
}

/* キーワードナビの非常時設定をクッキーに保存する */
function setKeywordNavigationOff()
{
    exp=new Date();
    exp.setTime(exp.getTime()+3153600000000);
    document.cookie = "mbikeynavi=off; expires=" + exp.toGMTString() + ";domain=multi-bits.com;path=/";
    alert('設定を保存しました');
}
function setKeywordNavigationOn()
{
    exp=new Date();
    exp.setTime(exp.getTime()+3153600000000);
    document.cookie = "mbikeynavi=; expires=" + exp.toGMTString() + ";domain=multi-bits.com;path=/";
    alert('設定を保存しました');
}

function viewIsMainPic()
{
    var bk = ___rnd;
    do {
        ___rnd = Math.floor( Math.random() * picArray.length );
    }
    while ( bk == ___rnd );
    var pic = picArray[ ___rnd ];

    $$('mainPic').html( pic );
    $$('top_imgid').html( cutImgId( pic ) );
}

function cutImgId( _str )
{
    var rObj = new RegExp("(imgId=)([0-9]{11})");
    var g = _str.match( rObj );
    return RegExp.$2;
}

function execSearch( _name )
{
    var _form = document.f;
    var _keyword = eval( '_form.' + _name + '.value');
    if ( $empty( _keyword ) ){
        alert("検索キーワードが指定されておりません。\n検索キーワードは必須です。");
        return false;
    }else{
        if( 'inputext2' == _name ){
            _form.k.value = _keyword;
            _form.md.value = 3;
            _form.submit();
        }else if( 'inputext1' == _name ){
            if(_form.up.value.length <= 0){
                alert("お客様のお手持ちの画像ファイルが指定されておりません。");
                return false;
            }else{
                _form.k.value = _keyword;
                _form.md.value = 4;
                _form.submit();
            }
        }
    }
    return false;
}

function set16Color(color){
    document.f.c1.value=color;
    document.getElementById('indicate').style.backgroundColor='#'+color;
    document.f.R.value=parseInt(color.substring(0,2),16);
    document.f.G.value=parseInt(color.substring(2,4),16);
    document.f.B.value=parseInt(color.substring(4,6),16);
}

function editRGB(){
    if( document.f.R.value > 255 || document.f.R.value < 0 ){alert("Rにご指定の値は0～255の範囲ではありません");return false;}
    if( document.f.G.value > 255 || document.f.G.value < 0 ){alert("Gにご指定の値は0～255の範囲ではありません");return false;}
    if( document.f.B.value > 255 || document.f.B.value < 0 ){alert("Bにご指定の値は0～255の範囲ではありません");return false;}

    if( document.f.R.value.match(/\D/) ){alert("Rにご指定の値は半角数字ではありません");return false;}
    if( document.f.G.value.match(/\D/) ){alert("Gにご指定の値は半角数字ではありません");return false;}
    if( document.f.B.value.match(/\D/) ){alert("Bにご指定の値は半角数字ではありません");return false;}

    R16 = to16(document.f.R.value);
    G16 = to16(document.f.G.value);
    B16 = to16(document.f.B.value);
    document.f.c1.value=R16+G16+B16;
    document.getElementById('indicate').style.backgroundColor='#'+R16+G16+B16;
}
function to16(a){
    a="0"+parseInt(a,10).toString(16).toUpperCase();
    a=a.substr(a.length-2,2)
    return a;
}

function OpenColorMap(){
    myWin = window.open( "colormap.htm", "win1", "toolbar=no,location=no,status=no,menubar=no,scrollbar=no,width=500,height=230");
}

// VCD - - - - - - - - - - - - - - - - - - - - - - -
function openCartsend(){
    document.cart.submit();
}

function dispFileSize( _byte )
{
    return Math.floor(_byte / 1024);
}

function submitDownload()
{
    var _tmp = new Array();
    for (var e in ITEMS )
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _tmp.push( e.substr(0,11) + e.substr(12,15) );
    }

    if( arrLength( ITEMS ) > 0 )
    {
        document.VCDDownload.target = "_blank";
        document.VCDDownload.i.value = _tmp.join('.');
        document.VCDDownload.submit();
        return true;
    }
    else
    {
        alert('バスケットが空です、ダウンロードする画像をバスケットに入れてから\nまとめてダウンロードをご利用下さい。');
        return false;
    }
}

function addDLBasketItem(_imgid,_imgtype)
{
    if( !exists( ITEMS[ _imgid + '_' + _imgtype ] ) )
    {
        var obj;
        eval("obj = img_" + _imgid + "['" + _imgid + "_" + _imgtype+"']" );
        ITEMS[ _imgid+'_'+_imgtype] = obj;
    }

    if( MAX_KBYTE_SIZE < dlBasketItemsTotalFileSize() )
    { 
        alert('一度にダウンロードバスケットに登録出来る合計ファイルサイズは'+MAX_KBYTE_SIZE+"Kbyteです。\nバスケットの中を整理するか、一度バスケットをDLしてください。\nバスケットの容量を１ファイルで超えてしまう場合、「今すぐダウンロード」をご利用下さい。");
        delDLBasketItem( _imgid + '_' + _imgtype ); 
    }
    else if( arrLength( ITEMS ) > MAX_FILE_NUM )
    {
        alert('一度にダウンロードバスケットに登録出来るファイル数は'+MAX_FILE_NUM+"です。\nバスケットの中を整理するか、一度バスケットをDLしてください。");
        delDLBasketItem( _imgid + '_' + _imgtype ); 
    }
    else
    {
        reloadDlBasketItemList();
        closeImgDetail();
    }
}

function delDLBasketItem( _id )
{
    delete ITEMS[ _id ];
    reloadDlBasketItemList();
    closeImgDetail();
}

function clearDlBasket()
{
    if(confirm("本当にバスケットをクリアしますか？"))
    {
        ITEMS = new Array();
        reloadDlBasketItemList();
        closeImgDetail();
    }
}

function openImgDetail( imgid )
{
    layerOpen('imgDetailLayer');

    var imgData;
    eval('imgData = img_'+imgid+';'); // var imgData = img_xxxccccvvvvv ;

    var _buf = new Array();
    for(var e in imgData)
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _buf.push('<table width="520" border="0" cellspacing="5" cellpadding="0" style="margin-top:10px;margin-bottom:10px;border-spacing:5px;" bgcolor="#ededed">');
        _buf.push(' <tr>');
        _buf.push('     <td align="left" bgcolor="#ffffff" valign="middle" style="padding:2px;text-indent:5px;" nowrap >');
        _buf.push('         <span class="bold">'+imgData[e].resX+'×'+imgData[e].resY+'</span> － '+ imgData[e].fileSize + 'KB(' + imgData[e].format + ')');
        _buf.push('     </td>');

        if( !exists(ITEMS[ imgData[e].imgId+'_'+imgData[e].imgType ]) ){
            _buf.push('     <td align="center" bgcolor="#ededed" width="144">');
            _buf.push('         <a href="" onclick="quickDownload(\'' + imgData[e].imgId + '\' , \'' + imgData[e].imgType + '\');return false" class="do_dl"><span class="img">ダウンロードする</span></a>');
            _buf.push('     </td>');
            _buf.push('     <td align="center" bgcolor="#ededed" width="144">');
            _buf.push('         <a href="" onclick="addDLBasketItem(\'' + imgData[e].imgId + '\',\'' + imgData[e].imgType + '\');return false" class="add_bskt"><span class="img">バスケットに追加</span></a>');
            _buf.push('     </td>');
        }else{
            //already added
            _buf.push('     <td align="center" bgcolor="#ededed" width="144"></td>');
            _buf.push('     <td align="center" bgcolor="#ededed" width="144">');
            _buf.push('         <a href="" onclick="delDLBasketItem(\'' + e + '\');return false" class="del_bskt"><span class="img">バスケットから削除</span></a>');
            _buf.push('     </td>');
        }
        _buf.push(' </tr>');
        _buf.push('</table>');
    }

    $('imgDetailLayerItemList').innerHTML = _buf.join('');
    delete _buf;

    $('QucikDetailVcd').href = "http://photo.designers-garage.jp/execute/ImageCatalogPickup?imgId=" + imgid;
    $('imgDetailLayer_imgid').innerHTML = imgid;
    $('imgDetailLayer_thumbpic').src = "http://photo.designers-garage.jp/img/thumb/" + imgid.substr(0,3) + "/" + imgid.substr(3,4) + "/" + imgid + "_jrp.jpg";
}

function closeImgDetail(){
    $$('imgDetailLayer').off();
}

function noop(){
    return;
}

// num=0~100
function barGraph(_num)
{
    $$('barGraph').attr('style', 'width:' + _num + '%;height:12px;background-color:#ff8500;' );
}

function opendlBasket(){
    layerOpen('dlBasketLayer')
    reloadDlBasketItemList();
    $('dlBasketTotalFileSize').innerHTML = dlBasketItemsTotalFileSize();
}

function closeDlBasket(){
    $$('dlBasketLayer').off();
}

function openBuyPcdForm(){
    window.open('http://photo.designers-garage.jp/form/vcd.htm');
}

function closeBuyPcdForm(){
    $$('buyPcdFormLayer').off();
}

//VCD合計ファイルサイズ計算
function dlBasketItemsTotalFileSize()
{
    var _total = 0;
    for(var e in ITEMS)
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _total += parseInt(ITEMS[e].fileSize);
    }
    return _total;
}

function arrLength(_var){
    var _i = 0;
    for(e in _var){
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _i++;
    }
    return _i;
}

function reloadDlBasketItemList()
{
    $('dlBasketTotalFileSize').innerHTML = dlBasketItemsTotalFileSize();
    $('dlBasketTotalFileNum').innerHTML = arrLength(ITEMS);

    var _buf = new Array();
    for(var e in ITEMS)
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _buf.push('<table width="159" border="0" cellspacing="0" cellpadding="0" class="result_imglist"><tr>');
        _buf.push('<td align="center" valign="middle" bgcolor="#ededed">');
        _buf.push(' <a name="hover" class="result_imglist_hover" id="bskt_aid' + e + '" style="text-decoration:none;"><span style="text-decoration:none;">');
        _buf.push(' <table width="137" border="0" cellspacing="0" cellpadding="0" class="result_imglist_table" style="text-decoration:none;">');
        _buf.push('     <tr>');
        _buf.push('         <td height="137" align="center" bgcolor="#ffffff">');
        _buf.push('             <a href="#" onclick="openImgDetail(\'' + e.substr(0,11) + '\');return false"><img src="http://photo.designers-garage.jp/img/thumb/' + e.substr(0,3)+ '/' + e.substr(3,4) + '/' + e.substr(0,11) + '_jrt.jpg" border=0 alt="photo" onerror="noImage( this, \'/img/font/no_image01.gif\')" /></a>');
        _buf.push('         </td>');
        _buf.push('     </tr>');
        _buf.push('     <tr valign="center">');
        _buf.push('         <td align="center" nowrap bgcolor="#ffffff" style="text-decoration:none;">');
        _buf.push( e );
        _buf.push('<br>');
        _buf.push( ITEMS[e].resX );
        _buf.push(' × ');
        _buf.push( ITEMS[e].resY )
        _buf.push('         </td>');
        _buf.push('     </tr>');
        _buf.push('     <tr valign="center">');
        _buf.push('         <td align="center" class="size-1 gray" valign="middle" bgcolor="#ffffff" style="padding:0px 0px 0px 0px;text-decoration:none;"><c:out value="${item.img_id}"/></td>');
        _buf.push('     </tr>');
        _buf.push('     <tr>');
        _buf.push('         <td align="center" valign="middle" bgcolor="#ffffff" style="padding:0px 0px 10px 0px;">');
        _buf.push('             <div style="background:url(/img/dot_1line.gif) repeat-x;height:1px;font-size:1px;line-height:1px;margin:5px 5px 10px 5px;" ></div>');
        _buf.push('             <a href="javascript:void(0);" class="do_bskt_delete" onclick="delDLBasketItem(\'' + e + '\');return false"><span class="img">この画像を削除する</span></a>');
        _buf.push('         </td>');
        _buf.push('     </tr>');
        _buf.push(' </table>');
        _buf.push(' </span></a>');
        _buf.push('</td></tr></table>');
    }
    $('dlBasketLayerItemList').innerHTML = _buf.join('');
    delete _buf;

    barGraph( parseInt( (dlBasketItemsTotalFileSize() / MAX_KBYTE_SIZE ) * 100 ) );
    reloadDlBtn();
}

function reloadDlBtn(){
    var _tmparr =  new Array( dlBtnArr.length );

    for(var e in dlBtnArr){
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _tmparr[ '' + e + '' ] = 'f';
    }

    for(var e in ITEMS)
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        _tmparr[ e.substr(0,11) ] = 't';
    }

    for(var e in _tmparr)
    {
        if( typeof(e) == 'string' && e == 'push' ) continue;
        if( _tmparr[e] == dlBtnArr[e])
        {
            // no change
        }
        else if( _tmparr[e] == 't' && dlBtnArr[e] == 'f')
        {
            //change enable
            $$('dlbtn' + e ).attr('style','background-position:0px -63px;');
            dlBtnArr[e] = _tmparr[e];

        }else if( _tmparr[e] == 'f' && dlBtnArr[e] == 't'){ //change disable
            $$('dlbtn' + e ).attr('style','background-position:0px 0px;');
            dlBtnArr[e] = _tmparr[e];
        }
    }

    delete _tmparr;
}


function exists(_var)
{
    if( typeof( _var ) == "undefined")
        return false;
    else
        return true;
}

function print(_var){
    document.write(_var);
}

//class ImgItem
function ImgItem( _imgid, _imgtype, _filesize, _resx, _resy, _format, _layer, _clippath){
    this.imgId = _imgid;
    this.imgType = _imgtype;
    this.fileSize = _filesize;
    this.resX = _resx;
    this.resY = _resy;
    this.format = _format;
    this.layer = _layer;
    this.clippath = _clippath;
    return this;
}

function quickDownload( _imgid, _imgtype )
{
    document.VCDDownload.target = "_blank";
    document.VCDDownload.i.value = _imgid + _imgtype;
    document.VCDDownload.submit();
}

function noDownload()
{
    alert('ダウンロード対象外商品です');
}


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
// ドラッグ移動オブジェクト
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function dragLay( layName, x, y )
{
    this.id      = layName;  // ドラッグできるようにするレイヤー名
    this.x       = x;        // 初期left位置
    this.y       = y;        // 初期top位置
}

//レイヤー移動プロトタイプ
dragLay.prototype.moveLAYoj = function moveLAYoj(x,y)
{
    var oj = $$(this.id).style;
    if( $G['IE'] || $G['Opera'] )
    {
        if($num(x))oj.pixelLeft = x;
        if($num(y))oj.pixelTop  = y;
    }
    else
    {
        if($num(x))oj.left = x + 'px';
        if($num(y))oj.top  = y + 'px';
    }
}

//--奥行きZ座標set 
function zLayer(obj,_z)
{
    obj.style.zIndex = _z;
}

//--マウスX座標get
function getMouseX(e)
{
    if( $G['Opera'] )
        return e.clientX;
    else if( $G['IE'] )
        return document.body.scrollLeft + event.clientX;
    else
        return e.pageX;
}

//--マウスY座標get
function getMouseY(e)
{
    if( $G['Opera'] )
        return e.clientY;
    else if( $G['Mac'] && $G['IE'] )
        return document.body.scrollTop + event.clientY;
    else if( $G['IE'] )
        return document.documentElement.scrollTop + event.clientY;
    else
        return e.pageY;
}

//--レイヤ－左辺X座標get
function getLEFT(layName)
{
    if( $G['Opera'] || $G['IE'] )
      return $$(layName).style.pixelLeft;
    else
      return ( $$(layName).style.left != "" ) ? parseInt( $$(layName).style.left ) : 0;
}

//--レイヤ－上辺Y座標get
function getTOP(layName)
{
    if( $G['Opera'] || $G['IE'] )
      return $$(layName).style.pixelTop;
    else
      return ( $$(layName).style.top != "" ) ? parseInt( $$(layName).style.top ) : 0;
}

//--マウスカーソルを動かした時レイヤーもmoveLAYojで動かす
function mmove(e)
{
    if( !window.clickElement ) return;
    var selLay;
    if ( !$empty(selLay = $$( clickElement )) )
    {
        var movetoX = getMouseX(e) - $L['offsetX'];
        var movetoY = getMouseY(e) - $L['offsetY'];
        var _limitX = $("ScreenSizePointer").offsetLeft - selLay.offsetWidth -5;
        var _limitY = $("ScreenSizePointer").offsetTop - selLay.offsetHeight -4;

        if ($L['offsetX'] < 0
         || $L['offsetY'] < 0
         || $L['offsetX'] > selLay.offsetWidth
         || $L['offsetY'] > selLay.offsetHeight )
        {
            zLayer( selLay, $L['zcount']++ );
            clickElement=null;
            return false;
        }
        else if( movetoX < 5 )
        {
            $L['offsetX'] = getMouseX(e) - getLEFT( selLay.id );
            $L['offsetY'] = getMouseY(e) - getTOP( selLay.id );
            movetoX = 5;
        }
        else if( movetoX > _limitX )
        {
            $L['offsetX'] = getMouseX(e) - getLEFT( selLay.id );
            $L['offsetY'] = getMouseY(e) - getTOP( selLay.id );
            movetoX = _limitX;
        }
        else if( movetoY < ($$("windowTopLimit").offsetTop + 4) )
        {
            $L['offsetX'] = getMouseX(e) - getLEFT( selLay.id );
            $L['offsetY'] = getMouseY(e) - getTOP( selLay.id );
            movetoY = $$("windowTopLimit").offsetTop + 4;
        }
        else if( movetoY > _limitY )
        {
            $L['offsetX'] = getMouseX(e) - getLEFT( selLay.id );
            $L['offsetY'] = getMouseY(e) - getTOP( selLay.id );
            movetoY = _limitY;
        }
        dragLay[ clickElement ].moveLAYoj( movetoX, movetoY );
        return false;
    }
}

//--マウスボタンを押し下げた時 レイヤー内のカーソルoffset位置取得
function mdown(e)
{
    if($G['Gecko'])
    {
        if(e.currentTarget.className != 'dragLays')
            return;
        else
            clickElement = e.currentTarget.id;
    }
    if ( $id( clickElement ) )
    {
        $L['offsetX'] = getMouseX(e) - getLEFT( clickElement );
        $L['offsetY'] = getMouseY(e) - getTOP( clickElement );
        zLayer( $$(clickElement) , $L['zcount']++ );
    }
    return false
}

//--マウスボタンを上げた時ドラッグ解除
function mup(e)
{
    if(!window.clickElement)
         return;

    if ( $$( clickElement ) )
    {
      zLayer( $$(clickElement) , $L['zcount']++ );
      clickElement=null;
    }
}

//ウインドウを開く
function layerOpen(_layerName)
{
    $L['ids'].push( _layerName );
    
    var scrY,scrX,bw,bh;
    if( $G['Mac'] && $G['IE'] )
    {
        scrY = document.body.scrollTop;
        scrX = document.body.scrollLeft;
        bw   = document.body.clientWidth;
        bh   = document.body.clientHeight;
    }
    else if( $G['IE'] || $G['Opera'] )
    {
        scrY = document.documentElement.scrollTop;
        scrX = document.documentElement.scrollLeft;
        bw   = document.body.clientWidth;
        bh   = document.body.clientHeight;
    }
    else
    {
        scrY = self.pageYOffset; 
        scrX = self.pageXOffset; 
        bw   = window.innerWidth;
        bh   = window.innerHeight;
    }

    $$( _layerName ).on();
    var previewL = $$(_layerName).style;
    if( $G['IE'] || $G['Opera'] )
    {
        previewL.pixelWidth = $$(_layerName).offsetWidth;
        previewL.pixelHeight = $$(_layerName).offsetHeight;
    }
    else
    {
        previewL.width = $$(_layerName).offsetWidth + "px";
        previewL.height = $$(_layerName).offsetHeight + "px";
    }

    var _left = (bw/2) - ( $$(_layerName).offsetWidth / 2 ) + scrX;
    if( $G['IE'] || $G['Opera'] )
        previewL.pixelLeft = _left;
    else
        previewL.left = _left + "px";

    var _top = $("windowTopLimit").offsetTop + 60;
    if (_top < scrY) _top = scrY + 75;

    if( $G['IE'] || $G['Opera'] )
        previewL.pixelTop = _top;
    else
        previewL.top = _top + "px";;

    dragLay[_layerName] = new dragLay(_layerName,_left,_top);
    $$(_layerName).style.zIndex = $L['zcount']++;

}

// 類似検索確認ウィンドウオープン
function ruijiInfoShow( _value )
{
    layerOpen('ruijiInfoLayer');

    //レイヤースタイル変更
    $$("ruijiInfoLayerHref").href = "javascript:resetRuijiIdCoockie('" + _value + "');";
    $$("ruijiInfoCloseHref").href = "javascript:ruijiInfoLayerClose();";

    return false;
}

// 類似検索確認ウィンドウクローズ
function ruijiInfoLayerClose()
{
    ruijiInfoL=$("ruijiInfoLayer").style;
    ruijiInfoL.visibility = "hidden";
}

// チェックついてたらクッキーにoffの値を書き込む
function resetRuijiIdCoockie( _value )
{
    if(document.ruijiInfoLayerForm.mbiruijiprompt.checked)
    {
        exp=new Date();
        exp.setTime(exp.getTime()+3153600000000);
        document.cookie = "mbiruijiprompt=off; expires=" + exp.toGMTString();
    }
    resetRuijiIdMain( _value ); //類似に渡す
    ruijiInfoLayerClose();  //ウィンドウ消す
}

function ruijiSampleShowImage(img_id)
{
    var makerid = img_id.substring(0,3);
    var cdid = img_id.substring(3,7);
    var picid = img_id.substring(7,11);
    var pic=new Image(); 
    pic.src="http://photo.designers-garage.jp/img/thumb/"+makerid+"/"+cdid+"/"+makerid+cdid+picid+"_jrt.jpg";
    document.images["ruijithumb"].src=pic.src;
}

// キーワードナビの非常時設定をクッキーに保存する
function setRuijiTableOff()
{
    var status = '';
    var exp=new Date();
    exp.setTime(exp.getTime()+3153600000000);
    if ( $$('quickRuijiTable').isview() )
    {
        status = 'off';
        $$('quickRuijiTable').off();
        $$('quickRuijiTableMSG').html('<a class="ruiji_onoffbtn" href="javascript:setRuijiTableOn();"><img src="/img/font/icon_plus.gif"> 類似画像検索を表示</a>');
    }
    else
    {
        $$('quickRuijiTable').on();
        $$('quickRuijiTableMSG').html('<a class="ruiji_onoffbtn" href="#qRJump" onClick="setRuijiTableOff()"><img src="/img/font/icon_minus.gif"> 類似画像検索を隠す</a>');
    }
    document.cookie = "mbiruiji="+status+"; expires=" + exp.toGMTString() + ";domain=multi-bits.com;path=/";
}

function setRuijiTableOn()
{
    var exp=new Date();
    exp.setTime( exp.getTime()+3153600000000 );
    document.cookie = "mbiruiji=; expires=" + exp.toGMTString() + ";domain=multi-bits.com;path=/";
    window.location.reload(true);
}

function isRuijiTable()
{
    if( document.cookie.match(/mbiruiji=off/) )
        return false;
    else
        return true;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function previewshow( img_id , _url , _cd_id , _title, _webOnly )
{
    var makerid = img_id.substring( 0, 3 );
    var cdid = img_id.substring( 3, 7 );
    var picid = img_id.substring( 7, 11 );
    var picurl = 'http://photo.designers-garage.jp/img/thumb/' + makerid + '/' + cdid + '/' + makerid + cdid + picid + '_jrp.jpg';

    document.previewpic.src = picurl;
    $$('QucikDetail').attr('href',_url);
    $$('MyPoket').attr('href','javascript:addToLightBoxWithCdid("' + img_id + '","' + _title + '")');
    $$('CDROM').attr('href','/execute/MediaImageCatalog?cdId=' + _cd_id + '&locale=ja');
    if ( _webOnly )
        $$("pLayerCDROM").off();
    else
        $$("pLayerCDROM").on();

    $$('preview_imgig').html( img_id );

    layerOpen('previewLayer');

    return false;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Quick Preview
function previewclose()
{
    document.previewpic.src = '/img/spacer.gif';
    $$('pLayerCDROM').off();
    $$('previewLayer').off();
}

function my_hex(n, len) {
    var out, i;
    out = "";
    for(i = 0; i < len; i++) {
    out = "0123456789ABCDEF".charAt(n & 0xf) + out;
    n >>= 4;
    }
    return out;
}

function my_escape(str) {
    var c, i, out;

    if(navigator.appName != "Microsoft Internet Explorer")
    return str.replace(/[^.0-9A-Z_a-z-]/g, function(s) {
        c = s.charCodeAt(0);
        if(c < 256)
        return "%" + my_hex(c, 2);
        return "%u" + my_hex(c, 4);
    });

    out = "";
    for(i = 0; i < str.length; i++) {
    c = str.charAt(i);
    if(c.match(/[^.0-9A-Z_a-z-]/)) {
        c = str.charCodeAt(i);
        if(c < 256)
        out += "%" + my_hex(c, 2);
        else
        out += "%u" + my_hex(c, 4);
    } else
        out += c;
    }
    return out;
}


