// Copyright (c) 2005 BAYLEAF CO.,LTD. All rights reserved.

/**
 *  �@�\�F �J�[�g�ҏW
 *  ���F QUICK CART��ҏW���܂��B
 *
 *  �T���v���F <script type="text/javascript">cart('/mt/plugins/BlogPlus/')</script>
 *
 *  �����F CGI PATH   : cgipath ------------�i�ȗ��j
 *                      ��j'/mt/plugins/BlogPlus/'
 *                          QUICK CART �� CGI PATH ��ݒ肵�܂��B�ȗ������/cgi-bin/���K�p����܂�
 */

var quickcart_flag = true;
var quickcart_url  = '';

function cart (cgipath)
{
    if (quickcart_flag)
    {
        var cgipath = cgipath ? cgipath : '/cgi-bin/';
        if (quickcart_url == '')
        {
            var quickcart_name = 'quickcart.js';
            var scripts        = document.getElementsByTagName('script');
            for (i=0; i< scripts.length; i++) if (scripts[i].src.indexOf(quickcart_name) > 0) quickcart_url = scripts[i].src.substr(0,scripts[i].src.indexOf(quickcart_name));
        }
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="180" height="250" id="quickcart" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="flashvars" VALUE="DATA='+location.href+'&amp;PROTOCOL='+location.protocol+'&amp;HOST='+location.hostname+'&amp;PATH='+cgipath+'">');
        document.write('<param name="movie" value="'+quickcart_url+'quickcart.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+quickcart_url+'quickcart.swf" quality="high" bgcolor="#ffffff" flashvars="DATA='+location.href+'&amp;PROTOCOL='+location.protocol+'&amp;HOST='+location.hostname+'&amp;PATH='+cgipath+'" width="180" height="250" name="quickcart" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="'+location.protocol+'://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
        document.write('<iframe id="tracking" name="tracking" src="/favicon.ico" border="0" style="width:0px; height:0px; border-width:0;"></iframe>');
    }
    quickcart_flag = false;
    return;
}

/**
 *  �@�\�F �I�[�_�[�{�^���ҏW
 *  ���F �ʏ�I�[�_�[�{�^���܂��́A�v���_�E���t���I�[�_�[�{�^����ҏW���܂��B
 *         ������ ''�i�V���O���R�[�e�[�V�����j�ň͂��Ă��������B
 *
 *  �T���v���F <script type="text/javascript">button('���i�`','1500','','#CC3300','#FFFFFF','500','30','http://www.quick-solution.com/item1.html')</script>
 *             <script type="text/javascript">button('���i�a','1500','�T�C�Y��w��,S,M,L,LL','#CC3300','#FFFFFF','500','30','http://www.quick-solution.com/item1.html')</script>
 *
 *  �����F ���i��     : name ------------�i�ȗ��s�j
 *                      ��j'���i�P'
 *                          ���i���ɏ��i�P��ݒ肵�܂��B�ȗ��ł��܂���B
 *
 *         ���i���i   : price -----------�i�ȗ��s�j
 *                      ��j'1500'
 *                          ���i���i��1500�~��ݒ肵�܂��B�ȗ��ł��܂���B
 *
 *         ���i�̎�� : variation -------�i�ȗ��j  ���v���_�E���t���{�^��
 *                      ��j'�T�C�Y��w��,S,M,L,LL'
 *                          �J���}��؂�ŕҏW���Ă��������B�P�Ԗڂɂ͌��o����ҏW���܂��B
 *                          �ȗ�����ƒʏ�{�^���ɂȂ�܂��B
 *
 *         �{�^���F   : btn_color -------�i�ȗ��j
 *                      ��j'#CC3300'
 *                          �{�^���̐F��Ԃɂ��܂��B�ȗ�����Ɛ��K�p����܂�
 *
 *         �w�i�F     : bg_color --------�i�ȗ��j
 *                      ��j'#000000'
 *                          �{�^���̔w�i�F��ɂ��܂��B�ȗ�����Ɣ����K�p����܂�
 *
 *         �ʑ���   : postage ---------�i�ȗ��j
 *                      ��j'500'
 *                          ��{�����Ƃ͕ʂɏ��i����500�~�̌ʑ�����ݒ肵�܂��B
 *                          0��ݒ肷��Ƒ��������ɂȂ�܂��B�ȗ�����Ɗ�{������K�p���܂�
 *
 *         �݌ɐ�     : stock -----------�i�ȗ��j
 *                      ��P�j'30'
 *                          �݌ɐ���30��ݒ肵�܂��B30�ȏ�J�[�g�ɓ���܂���B
 *                          �ȗ�����Ɩ����ɃJ�[�g�ɓ���܂�
 *                      ��Q�j'B'
 *                          A�`D��ݒ肷��ƃ{�^���̕\�����ς��܂��B
 *                         �iA:�݌ɐ؂�AB:���ב҂��AC:���ז���AD:�̔��I���j
 *
 *         ���i�t�q�k : item_url --------�i�ȗ��j
 *                      ��j'http://www.quick-solution.com/item1.html'
 *                          ���i�y�[�W��URL��ݒ肷�邱�Ƃ��o���܂��B
 *                          �ȗ������location.href��K�p���܂�
 */
function button (name, price, variation, btn_color, bg_color, postage, stock, item_url)
{
    var reg         = new RegExp(',','g')
    var price       = price.replace(reg,'');
    if (postage)
    {
        var postage = postage.replace(reg,'');
        if (isNaN(price)||isNaN(postage))
        {
            price   = '';
            postage = '';
        }
    }else{
        price       = !isNaN(price) ? price     : '';
    }
    var variation   = variation     ? variation : '';
    var btn_color   = btn_color     ? btn_color : '';
    var bg_color    = bg_color      ? bg_color  : '';
    var postage     = postage       ? postage   : '';
    var stock       = stock         ? stock     : '';
    var item_url    = item_url      ? item_url  : location.href;

    if (quickcart_url == '')
    {
        var quickcart_name = 'quickcart.js';
        var scripts        = document.getElementsByTagName('script');
        for (i=0; i< scripts.length; i++) if (scripts[i].src.indexOf(quickcart_name) > 0) quickcart_url = scripts[i].src.substr(0,scripts[i].src.indexOf(quickcart_name));
    }

    if (variation)
    {
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100" height="70" id="quickvariation" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="flashvars" VALUE="DATA='+item_url+','+name+','+(postage?price+'('+postage+')':price)+',1,'+stock+','+(btn_color?'0x'+btn_color.substr(1):'')+','+(bg_color?'0x'+bg_color.substr(1):'')+'&amp;VARIATION='+variation+'">');
        document.write('<param name="movie" value="'+quickcart_url+'quickvariation.swf" /><param name="quality" value="high" /><param name="bgcolor" value="'+(bg_color?bg_color:'#ffffff')+'" /><embed src="'+quickcart_url+'quickvariation.swf" quality="high" bgcolor="'+(bg_color?bg_color:'#ffffff')+'" flashvars="DATA='+item_url+','+name+','+(postage?price+'('+postage+')':price)+',1,'+stock+','+(btn_color?'0x'+btn_color.substr(1):'')+','+(bg_color?'0x'+bg_color.substr(1):'')+'&amp;VARIATION='+variation+'" width="100" height="70" name="quickvariation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="'+location.protocol+'://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
    } else {
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100" height="25" id="quickorder" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="flashvars" VALUE="DATA='+item_url+','+name+','+(postage?price+'('+postage+')':price)+',1,'+stock+','+(btn_color?'0x'+btn_color.substr(1):'')+','+(bg_color?'0x'+bg_color.substr(1):'')+'">');
        document.write('<param name="movie" value="'+quickcart_url+'quickorder.swf" /><param name="quality" value="high" /><param name="bgcolor" value="'+(bg_color?bg_color:'#ffffff')+'" /><embed src="'+quickcart_url+'quickorder.swf" quality="high" bgcolor="'+(bg_color?bg_color:'#ffffff')+'" flashvars="DATA='+item_url+','+name+','+(postage?price+'('+postage+')':price)+',1,'+stock+','+(btn_color?'0x'+btn_color.substr(1):'')+','+(bg_color?'0x'+bg_color.substr(1):'')+'" width="100" height="25" name="quickorder" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="'+location.protocol+'://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
    }
    return;
}
